問題描述
是什么讓線程的執行順序不可預測?調度程序是否在某個時候使用隨機數或檢查系統資源或查看哪個線程已等待足夠長的時間或...?
What makes the execution order of threads unpredictable? Does the scheduler at some point use random numbers or check system resources or see which thread has waited long enough or ...?
推薦答案
調度器通常是操作系統的調度器.它受許多因素的影響,包括機器上的其他進程在做什么,硬件在做什么(中斷)等.根據操作系統,我想有時可能會涉及隨機數,但我懷疑一般不會.更多的只是多個可變時間間隔可以重疊的不可預測的方式.
The scheduler is, usually, the OS's scheduler. It is influenced by many factors, including what other processes on the machine are doing, what the hardware is doing (interrupts), etc. Depending on the OS, I suppose there may sometimes be random numbers involved, but I suspect generally not. It's more just the unpredictable way that multiple variable time intervals can overlap.
這篇關于是什么讓線程的執行順序不可預測?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!