RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
[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://sczitong.cn/article/ipioih.html