}
//主线程计算量为总数的一半
int main(void)
{
printf("Please input the number:");
scanf("%d",&cs);
cs=cs*1000000;
printf("Please input the number for generating the data once:");
scanf("%d",&t);
t=t*100000;
pthread_t id;
int ret;
srand( (unsigned)time( NULL ) );
pthread_mutex_init(&mutex,NULL);//声明互斥锁
ret=pthread_create(&id,NULL,(void *)thread,NULL); //创建 thread 线程
gettimeofday(&start,NULL); //记录开始时间
int i=0,j=0;
double x,y;
long double data_main[t];
for(i=0;i
printf("Cost time=%f second \n",diffsec);
printf("roop times=%d \n",cs);
printf("effective times=%d \n",count);
printf("pi= %f \n",4*(double)count/(double)cs);
return(0);
}