gitlab.com/Raven-IO/raven-delve@v1.22.4/_fixtures/hcbpcountstest.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "math/rand" 6 "runtime" 7 "sync" 8 "time" 9 ) 10 11 func demo(id int, wait *sync.WaitGroup) { 12 for i := 0; i < 100; i++ { 13 sleep := rand.Intn(10) + 1 14 runtime.Breakpoint() 15 fmt.Printf("id: %d step: %d sleeping %d\n", id, i, sleep) 16 time.Sleep(time.Duration(sleep) * time.Millisecond) 17 } 18 19 wait.Done() 20 } 21 22 func main() { 23 wait := new(sync.WaitGroup) 24 wait.Add(1) 25 wait.Add(1) 26 go demo(1, wait) 27 go demo(2, wait) 28 29 wait.Wait() 30 }