爱问知识人 爱问教育 医院库

linuxC互斥线程池是什么?

首页

linuxC互斥线程池是什么?

linuxC互斥线程池是什么?

提交回答

全部答案

    2017-07-28 00:13:02
  •   C代码  #include
      #include   #include   #include   #define MAXS 1000  #define MAXTDS 5 //线程池大小  double myjg[MAXS+1];//计算结果存放位置  int max;  pthread_mutex_t mylock,eventlock;  pthread_cond_t myevent;  pthread_t threads[MAXTDS+2];   //线程池,完成1/n计算  int isend=0;  void *mycomp(void *x){//计算1/i的结果,计算结果放在一个数组中。
        int i=0;  while (1){  pthread_mutex_lock(&mylock);  if (myjg[0]=max){//计算完毕,退出线程  isend=1; //深未来技术http://deepfuture。javaeye。
      com/  break;  }  }  }  void *myprint1(void *xx){//读取数组,将计算结果累加,最终完成1/1+1/2+1/3+。。。。。。+1/n的计算  int maxi;  int curi=1;  double jg=0;  while(curiMAXS){//n的最大值  printf("please input an integer:(<=%d)",MAXS);  };  //深未来技术http://deepfuture。
      javaeye。
      com/  myjg[0]=0;  pthread_create(&(threads[0]),NULL,myprint1,NULL);  pthread_create(&(threads[1]),NULL,myprint2,NULL);  for (int i=2;i<=MAXTDS;i++){  pthread_create(&(threads[i]),NULL,mycomp,NULL);  sleep(1);  }  sleep(1);  return(0); 。

    活***

    2017-07-28 00:13:02

类似问题

换一换
  • 系统软件 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):