The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
yangbuwei

go 中让出时间片和顺序执行的区别?

  •  
  •   yangbuwei · Oct 15, 2018 · 3321 views
    This topic created in 2782 days ago, the information mentioned may be changed or developed.
    如题,既然如此那我让时间片存在的的意义何在呢?直接顺序执行不就好了?我能想到唯一的好处就是主协程等待其他协程用完,本人刚刚开始自学 go,想到什么问什么,要是比较弱智希望不要喷我。
    7 replies    2018-10-16 10:13:42 +08:00
    reus
        1
    reus  
       Oct 15, 2018
    不知道你在想什么,建议学习操作系统课程,多进程多线程部分,思而不学则殆啊
    yangbuwei
        2
    yangbuwei  
    OP
       Oct 15, 2018
    @reus 我的意思是他具体应用在哪些场景
    mengzhuo
        3
    mengzhuo  
       Oct 15, 2018
    同 1L 看不懂,应用层程序是不知道时间片存在的。

    我猜你是指:runtime.Gosched()
    https://golang.org/pkg/runtime/#Gosched
    文档说得很清楚了。
    Gosched yields the processor, allowing other goroutines to run. It does not suspend the current goroutine, so execution resumes automatically.
    tourist2018
        4
    tourist2018  
       Oct 15, 2018
    @yangbuwei #2 runtime.Gosched() 单纯这个方法在项目里面用的确实不多 但这是语言特性 你非得和应用结合什么鬼
    yangbuwei
        5
    yangbuwei  
    OP
       Oct 16, 2018
    @tourist2018 我都说了,我刚刚看到那一块,,所以问一下,你回答就回答,秀优越是什么鬼?什么鬼?
    yangbuwei
        6
    yangbuwei  
    OP
       Oct 16, 2018
    @mengzhuo 我其实说的不是应用层,,而是说在实际使用的时候,它用在什么场景,,不过你已经说明白了,感谢
    tourist2018
        7
    tourist2018  
       Oct 16, 2018
    @tourist2018 #4 你觉得是秀优越 好吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   928 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:32 · PVG 04:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.