1
2
3
4
5
6
7 package main
8
9 import (
10 "runtime"
11 "time"
12 )
13
14 func main() {
15 c := make(chan bool, 1)
16 go f1(c)
17 <-c
18 time.Sleep(10 * time.Millisecond)
19 go f2(c)
20 <-c
21 }
22
23 func f1(done chan bool) {
24 defer func() {
25 recover()
26 done <- true
27 runtime.Goexit()
28 }()
29 panic("p")
30 }
31
32 func f2(done chan bool) {
33 defer func() {
34 recover()
35 done <- true
36 runtime.Goexit()
37 }()
38 time.Sleep(10 * time.Millisecond)
39 runtime.GC()
40 panic("p")
41 }
42
View as plain text