mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2024-10-11 14:25:05 +00:00
Go 1.14 调度调整
This commit is contained in:
parent
955d90d536
commit
03257374c7
@ -146,7 +146,7 @@ func main() {
|
||||
|
||||
## 独占CPU导致其它Goroutine饿死
|
||||
|
||||
Goroutine是协作式抢占调度,Goroutine本身不会主动放弃CPU:
|
||||
Goroutine 是协作式抢占调度(Go1.14版本之前),Goroutine本身不会主动放弃CPU:
|
||||
|
||||
```go
|
||||
func main() {
|
||||
@ -197,6 +197,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
Go1.14 版本引入基于系统信号的异步抢占调度,可以避免 Goroutine 饿死的情况。
|
||||
|
||||
## 不同Goroutine之间不满足顺序一致性内存模型
|
||||
|
||||
因为在不同的Goroutine,main函数中无法保证能打印出`hello, world`:
|
||||
|
Loading…
Reference in New Issue
Block a user