問(wèn)題描述
是什么讓線程的執(zhí)行順序不可預(yù)測(cè)?調(diào)度程序是否在某個(gè)時(shí)候使用隨機(jī)數(shù)或檢查系統(tǒng)資源或查看哪個(gè)線程已等待足夠長(zhǎng)的時(shí)間或...?
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 ...?
推薦答案
調(diào)度器通常是操作系統(tǒng)的調(diào)度器.它受許多因素的影響,包括機(jī)器上的其他進(jìn)程在做什么,硬件在做什么(中斷)等.根據(jù)操作系統(tǒng),我想有時(shí)可能會(huì)涉及隨機(jī)數(shù),但我懷疑一般不會(huì).更多的只是多個(gè)可變時(shí)間間隔可以重疊的不可預(yù)測(cè)的方式.
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.
這篇關(guān)于是什么讓線程的執(zhí)行順序不可預(yù)測(cè)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!