关于线程休眠的问题
以下代码可以使当前线程休眠1秒钟后继续往下执行,但当要休眠毫秒时,不知改怎样些,比如要线程休眠600毫秒。
pthread_cond_t mycond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER;
struct timespec ts;
ts.tv_sec = time(NULL)+1;
ts.tv_nsec = 0;
pthread_mutex_lock(&mymutex);
pthread_cond_timedwait(&mycond, &mymutex ,(const struct timespec *)&ts);
pthread_mutex_unlock(&mymutex);
------解决方案--------------------select
行不?