Posix threads problem

后端 未结 6 980
暗喜
暗喜 2021-01-17 02:12

I am trying to understand pthreads by example. I have made the following code that is giving different answers everytime I run! Could anyone explain the bug please? TIA, Svi

6条回答
  •  我在风中等你
    2021-01-17 02:35

    If you mean the order of the answers, yes, it will be different since which thread runs is decided by the Linux scheduler.

    To elaborate: Once you create your threads, the order in which they get CPU time depends on the underlying OS scheduler(here, Linux scheduler). This may not be the same everytime.

提交回复
热议问题