Исходники и презентации
This commit is contained in:
22
lessons/channels/increment_with_channel/main.go
Normal file
22
lessons/channels/increment_with_channel/main.go
Normal file
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ch := make(chan int)
|
||||
|
||||
go func() {
|
||||
ch <- 1
|
||||
}()
|
||||
go func() {
|
||||
ch <- 1
|
||||
}()
|
||||
|
||||
value := 0
|
||||
value += <-ch
|
||||
value += <-ch
|
||||
|
||||
fmt.Println(value)
|
||||
}
|
||||
Reference in New Issue
Block a user