欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

[Linux線程]使用pthread_create函數(shù)的arg參數(shù)

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
//線程處理函數(shù)
void *threaddeal(void *arg)
{
  printf("%d\n",*((int *)arg));  //傳遞線程的參數(shù)
  pthread_exit(NULL);
}

int main(int argc,char *argv[])
{
  int i;
  pthread_t threadid;
  for(i=0;i<10;i++)
  {
    if(pthread_create(&threadid,NULL,threaddeal,&i) != 0)  //將i值作為參數(shù)傳遞
    {
      //返回值不為0則表明創(chuàng)建線程失敗
      printf("創(chuàng)建線程失敗.\n");
      exit(0);    //退出
    }
  }
  pthread_exit(NULL);
  return 0;
}

本文標(biāo)題:[Linux線程]使用pthread_create函數(shù)的arg參數(shù)
分享地址:http://chinadenli.net/article16/pdssgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、動態(tài)網(wǎng)站、網(wǎng)站營銷、靜態(tài)網(wǎng)站、軟件開發(fā)外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)