Исходники и презентации
This commit is contained in:
21
lessons/channels/channel_data_race/main.go
Normal file
21
lessons/channels/channel_data_race/main.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import "sync"
|
||||
|
||||
// go run -race main.go
|
||||
|
||||
var buffer chan int
|
||||
|
||||
func main() {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(100)
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
buffer = make(chan int)
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user