Posix threads problem

后端 未结 6 924
暗喜
暗喜 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:22

    I realize this post is old, but, alternatively, you may use a pthread_exit() at the end of main() so that main() will wait for all its peer threads to finish before exiting prematurely.

提交回复
热议问题