Posix threads problem

后端 未结 6 927
暗喜
暗喜 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

    Ok, finally added the extracode as suggested by the experts and it works fine now. Thanks again to all. :)

    for ( t = 0; t < NUM_THREADS; t++ ) {
        (void) pthread_join(threads[t], NULL);
    }
    

提交回复
热议问题