多线程调用sleep 有关问题
多线程调用sleep 问题
大家好,现在遇到一个多线程调用sleep问题,就是在创建了多个线程,共用了一个thread_loop线程函数,但线程函数中用到了一个sleep(n)的延时操作,感觉这样用有问题,sleep会被线程间互相覆盖,请问还会有什么其他的办法可以避免这种情况,求高人指点。。。
------解决思路----------------------
he sleep() function shall cause the calling thread to be suspended from execution...
what you probably need is a mean to sync the execution among threads...
Barrier
Mutex
Semaphore
大家好,现在遇到一个多线程调用sleep问题,就是在创建了多个线程,共用了一个thread_loop线程函数,但线程函数中用到了一个sleep(n)的延时操作,感觉这样用有问题,sleep会被线程间互相覆盖,请问还会有什么其他的办法可以避免这种情况,求高人指点。。。
------解决思路----------------------
he sleep() function shall cause the calling thread to be suspended from execution...
what you probably need is a mean to sync the execution among threads...
Barrier
Mutex
Semaphore