go:concurrency:channel
Table of Contents
Channel
What is it?
A channel is a typed conduit for sending and receiving values between goroutines. It helps coordinate and synchronize concurrent work.
What is it used for?
- Pass data safely between goroutines.
- Avoid complicated shared-memory locking.
Example
package main import "fmt" func main() { ch := make(chan int) go func() { ch <- 10 // send }() v := <-ch // receive fmt.Println(v) }
Hard words (English)
- conduit /ˈkɑːnduɪt/: “ống dẫn”/kênh truyền
- coordinate /koʊˈɔːrdɪneɪt/: điều phối
- synchronize /ˈsɪŋkrənaɪz/: đồng bộ
- shared memory /ʃerd ˈmeməri/: bộ nhớ dùng chung
- locking /ˈlɑːkɪŋ/: khóa (để tránh race)
go/concurrency/channel.txt · Last modified: by phong2018
