第2章 线程引入N.pptVIP

  • 1
  • 0
  • 约2千字
  • 约 26页
  • 2017-08-23 发布于河南
  • 举报
第2章 线程引入N

2.7 线程的引入;Linux中的线程编程;简单多线程程序;int main(void) { pthread_t id; int i,ret; ret=pthread_create(id,NULL,(void *) thread,NULL); if(ret!=0){ printf (Create pthread error!\n); exit (1); } for(i=0;i3;i++) printf(This is the main process.\n); return (0); } ;我们编译此程序: gcc example1.c -lpthread -o example1 运行example1,我们得到如下结果: This is the main process. This is a pthread. This is the main process. This is the main process. This is a pthread. This is a pthread. ;再次运行,我们可能得到如下结果: This is a pthread. This is the main process. This is a pthread. This is the main process. This is a pthread. This is the main proce

文档评论(0)

1亿VIP精品文档

相关文档