Created
July 18, 2019 05:07
-
-
Save Orenoid/1cd0276658e91d08f4210eeaa18e7d37 to your computer and use it in GitHub Desktop.
go code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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