Order of running threads in pthreads

后端 未结 4 1642
挽巷
挽巷 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:48

    The start tell the OS "start doing this". The joins say "wait until this is done".

    Now you are telling the OS "do this" and "do this". The OS can pick any order. But most of the time it will just do it in the order you told it to.

    It's like ordering two sammies at subways. 99% of the time you'll get them made in the same order you asked for them. But every blue moon, you won't. But you are still waiting for both of them before you pay :)

提交回复
热议问题