Source file
test/fixedbugs/issue11256.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "runtime"
14 "sync/atomic"
15 "time"
16 )
17
18 func main() {
19
20 runtime.GOMAXPROCS(2)
21
22 var x [100][]byte
23
24 for i := range x {
25 var done int32
26
27 go func() {
28
29
30
31
32
33 var buf [1024]byte
34 buf[0]++
35 for atomic.LoadInt32(&done) == 0 {
36 runtime.Gosched()
37 }
38 atomic.StoreInt32(&done, 0)
39
40 runtime.Goexit()
41 }()
42
43
44 x[i] = make([]byte, 1024*1024)
45
46
47 time.Sleep(50 * time.Microsecond)
48 atomic.StoreInt32(&done, 1)
49 for atomic.LoadInt32(&done) == 1 {
50 runtime.Gosched()
51 }
52 }
53 }
54
View as plain text