Tag: 线程睡眠

睡眠function是睡眠所有线程还是只调用它的人?

我在linux(Centos)上用pthread编程? 我想让线程在短时间内等待一些事情。 我正在尝试使用sleep(),nanosleep()或者usleep(),或者也许可以做到这一点。 我想问一下:睡眠function是睡眠所有线程还是只调用它的人? 任何建议或参考将不胜感激。 void *start_routine () { /* I just call sleep functions here */ sleep (1); /* sleep all threads or just the one who call it? what about nanosleep(), usleep(), actually I want the threads who call sleep function can sleep with micro-seconds or mili-seconds. */ … } int main (int […]