Go语言并发之并发实现、多核CPU设置、多协程间的通信、select、多协程间的同步
目录结构
├── gorotine
│ └── gorotine.go
└── main.go
----
并发实现...time.Sleep(time.Second * 5)
//运行结果:1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,
}
多核CPU...time.Sleep(time.Second * 5)
//运行结果:1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,
}
多协程间的通信...//结果:
/*
num: 1
num: 2
num: 3
timeout...
*/
}
多协程间的同步