gitlab.com/Raven-IO/raven-delve@v1.22.4/_fixtures/bpcountstest.go (about)

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