package main
import (
"fmt"
"runtime"
)
func test(c chan bool, n int) {
x := 0
for i := 0; i < 1000000000; i++ {
x += i
}
println(n, x)
if n == 9 {
c <- true
}
}
func main() {
runtime.GOMAXPROCS(1) //设置cpu的核的数量,从而实现高并发
c := make(chan bool)
for i := 0; i < 10; i++ {
go test(c, i)
}
<-c
fmt.Println("main ok")
}
/**
*
* __ (__`\
* (__`\ \\`\
* `\\`\ \\ \
* `\\`\ \\ \
* `\\`\#\\ \#
* \_ ##\_ |##
* (___)(___)##
* (0) (0)`\##
* |~ ~ , \##
* | | \##
* | /\ \## __..---'''''-.._.._
* | | \ `\## _.--' _ `.
* Y | \ `##' \`\ \
* / | \ | `\ \
* /_...___| \ | `\\
* / `. | / ##
* | | | / ####
* | | | / ####
* | () () | \ | | _.-' ##
* `. .' `._. |______..| |-'|
* `------' | | | | | || |
* | | | | | || |
* | | | | | || |
* | | | | | || |
* _____ | | | |____| || |
* / `` |-`/ ` |` |
* \________\__\_______\__\
* """"""""" """""""'"""
* Don't be a fucking stupid donkey! No, this is a fucking mule!
*/