#include
#include
#include
volatile static int nCount = 0;
void* frk_thread(void *param)
{
while(1)
{
printf("nCount=%d\n", nCount);
nCount++;
usleep(100000);
}
}
int main()
{
int nStart;
int nEnd;
pthread_t thread_frk;
pthread_create(&thread_frk, NULL, frk_thread, NULL);
nStart = nCount;
while(1)
{
nEnd = nCount;
if(nEnd - nStart >= 100)
break;
//printf("%d-%d=%d\n", nEnd, nStart, nEnd-nStart);
}
printf("over !\n");
return 0;
}
gcc -Wall -O2 tc.c -o tc -lpthread
阅读(650) | 评论(0) | 转发(0) |