Created
November 29, 2020 15:54
-
-
Save minhphong306/33cf8db953fdab4d30b55b34d177a26a to your computer and use it in GitHub Desktop.
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" | |
"sync" | |
) | |
func read(wg *sync.WaitGroup, data <-chan string) { | |
fmt.Println(<-data) | |
wg.Done() | |
} | |
func write(data chan<- string) { | |
data <- "Có làm thì mới có ăn" | |
} | |
func main() { | |
wg := &sync.WaitGroup{} | |
wg.Add(1) | |
unbuffer := make(chan string) | |
go write(unbuffer) | |
go read(wg, unbuffer) | |
wg.Wait() | |
//time.Sleep(1 * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment