github.com/lemon-mint/libuseful@v1.3.1-0.20220724073654-ee73785d5aa0/example/pid/pid.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"runtime"
     6  	"sync"
     7  
     8  	"github.com/lemon-mint/libuseful"
     9  )
    10  
    11  func main() {
    12  	fmt.Println(libuseful.GetPID())
    13  	var wg sync.WaitGroup
    14  	wg.Add(100)
    15  	for i := 0; i < 100; i++ {
    16  		go func() {
    17  			fmt.Println(libuseful.GetPID())
    18  			for i := 0; i < 1000; i++ {
    19  				runtime.Gosched()
    20  			}
    21  			wg.Done()
    22  		}()
    23  	}
    24  	wg.Wait()
    25  }