Last active
April 18, 2019 08:16
-
-
Save yakuter/2bca740da460cb9df0fae2dd200f2706 to your computer and use it in GitHub Desktop.
Buffered Kanal Örneği
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
bufferedKanal := make(chan string, 3) | |
go func() { | |
bufferedKanal <- "birinci" | |
fmt.Println("1. Gönderildi") | |
bufferedKanal <- "ikinci" | |
fmt.Println("2. Gönderildi") | |
bufferedKanal <- "üçüncü" | |
fmt.Println("3. Gönderildi") | |
}() | |
<-time.After(time.Second * 1) | |
go func() { | |
ilkOkunan := <-bufferedKanal | |
fmt.Println("Alınıyor...") | |
fmt.Println(ilkOkunan) | |
ikinciOkunan := <-bufferedKanal | |
fmt.Println(ikinciOkunan) | |
ucuncuOkunan := <-bufferedKanal | |
fmt.Println(ucuncuOkunan) | |
}() | |
<-time.After(time.Second * 5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment