[Linux线程]使用pthread_create函数来创建一个线程

#include 
#include 
#include 
//新线程首先运行的函数
void *threaddeal(void *arg)
{
  printf("这是一个新线程.\n");  //输出新线程提示
}
int main(int arg,char *argv[])
{
  pthread_t threadid;   //线程的标识符
  if(pthread_create(&threadid,NULL,threaddeal,NULL) != 0)   
  //创建一个新县城,然后运行threaddeal函数
  {
    //如果返回值不是0则表示创建线程失败
    printf("%s错误出现在第%s行",__FUNCTION__,__LINE__);  //打印错误信息
    exit(0);
  }
  else
  {
    sleep(1);    //挂起1秒等待线程运行
  }
  return 0;
}

文章题目:[Linux线程]使用pthread_create函数来创建一个线程
分享路径:http://www.kmzsk.com/article/ipioih.html

其他资讯

Copyright © 2026 昆明姝彩聂商贸有限公司 All Rights Reserved 滇ICP备2025072963号-9
友情链接: 成都企业网站建设 四川成都网站制作 成都网站建设 网站制作 成都网站设计 高端网站建设 营销型网站建设 重庆企业网站建设 网站建设 网站制作 成都网站建设 网站建设推广 定制网站制作 成都网站建设 重庆网站建设 广安网站设计 营销网站建设 上市集团网站建设 成都网站制作 成都网站建设 外贸网站设计方案 成都网站建设公司