Order of running threads in pthreads

后端 未结 4 1639
挽巷
挽巷 2021-01-26 11:58

In the following program, what are the possibilities for the ordering of threads? Assuming \"function\" will print thread id which is unique (since here we have only one process

4条回答
  •  一整个雨季
    2021-01-26 12:40

    I don't think there will be any specific ordering. Threads on the modern machines are executed in parallel and its not deterministic which thread's print statements will get executed first !

    The only ordering constraint that can be assumed is that thread 2 will come before thread 1 because of second pthread_join

提交回复
热议问题