What exactly does runtime.Gosched do?

前端 未结 2 1709
半阙折子戏
半阙折子戏 2020-12-02 04:15

In a version prior to the release of go 1.5 of the Tour of Go website, there\'s a piece of code that looks like this.

package main

import (
    \"fmt\"
             


        
2条回答
  •  暖寄归人
    2020-12-02 05:07

    Cooperative scheduling is the culprit. Without yielding, the other (say "world") goroutine may legally get zero chances to execute before/when main terminates, which per specs terminates all gorutines - ie. the whole process.

提交回复
热议问题