Order of running threads in pthreads

后端 未结 4 1676
挽巷
挽巷 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

    It is like a factory. Got two workers. One needs a bit of coffee and therefore starts a little later at the same task as the other one (well takes time for the kettle). Then that worker is firing on all cylinders but the coffee takes effect. Needs to use the loo. So the one that started earlier finished first but spent more time working. If only that worker had a bucket?!

提交回复
热议问题