- 论坛徽章:
- 0
|
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<prthread.h>
#include<errno.h>
prthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;
int lock_var;
time_t end_time;
void prthread1(void *arg);
int main{
prthread_t id1;
prthread_t mon_th_id;
int m;
end_time=time(NULL)+10;
thread_mutex_init(&mutex,NULL);
if((m=pthread_create(&id1,NULL,(void*)pthread1,NULL))<0){
printf("error");
}
pthread_join(id1,NULL);
exit(0);
}
void pthread1(void *arg))
{
int i;
while(time(NULL)<end_time){
if(pthread_mutex_lock(&mutex)<0){
perror("error");
}
for(i==0;i<3;i++){
lock_var++;
}
if(pthread_mutex_unlock(&mutex)<0){
perror("error");
}
exit(0);
}
这个程序里
prthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;
int lock_var;
time_t end_time;
算什么?宏吗?但是没有#define啊
请教下
还有prthread_t mon_th_id;和end_time=time(NULL)+10;是什么意思? |
|