pthread sleep linux

前端 未结 5 2074
孤独总比滥情好
孤独总比滥情好 2020-12-09 02:55

I am creating a program with multiple threads using pthreads.

Is sleep() causing the process (all the threads) to stop executing or just the thread whe

5条回答
  •  醉酒成梦
    2020-12-09 03:44

    sleep() function does not cease a specific thread, but it stops the whole process for the specified amount of time. For stopping the execution of a particular thread, we can use one pthread condition object and use pthread_cond_timedwait() function for making the thread wait for a specific amount of time. Each thread will have its own condition object and it will never receive a signal from any other thread.

提交回复
热议问题