当前位置: 技术问答>linux和unix
线程sleep的问题
来源: 互联网 发布时间:2016-11-16
本文导语: 代码如下: /* thread.h */ #ifndef THREAD_H #define THREAD_H #include #include #define MAXTHREADNUM 50 #define THREADNUM 1 extern pthread_key_t p_key; void threadMain(void); #endif /* thread.cc */ #include "thread.h" #include pthread_key_t p...
代码如下:
/* thread.h */
#ifndef THREAD_H
#define THREAD_H
#include
#include
#define MAXTHREADNUM 50
#define THREADNUM 1
extern pthread_key_t p_key;
void threadMain(void);
#endif
/* thread.cc */
#include "thread.h"
#include
pthread_key_t p_key;
void threadMain(void){
int times=0;
int *tid=(int *)pthread_getspecific(p_key);
while(times++