Skip to content

Instantly share code, notes, and snippets.

@Orenoid
Created July 18, 2019 05:07
Show Gist options
  • Save Orenoid/1cd0276658e91d08f4210eeaa18e7d37 to your computer and use it in GitHub Desktop.
Save Orenoid/1cd0276658e91d08f4210eeaa18e7d37 to your computer and use it in GitHub Desktop.
go code
package main
import "fmt"
import "time"
import "runtime"
func counter(name string){
for n:=0;n<20;{
n++
fmt.Println(name, "is", n)
// time.Sleep(100 * time.Millisecond)
// runtime.Gosched()
}
}
func main(){
fmt.Println("CPU number:", runtime.NumCPU())
runtime.GOMAXPROCS(2)
go counter("a")
go counter("b")
time.Sleep(100 * time.Millisecond)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment