当前位置: 首页 > news >正文

网站制作的书籍深圳网络营销策划有限公司

网站制作的书籍,深圳网络营销策划有限公司,合肥序曲网站建设公司怎么样,小企业做网站怎么做问题:编写程序完成如下功能:程序创建2个线程,然后: 1> 主线程先打印“I am main thread”,然后睡眠2秒后,打印"main thread wake up",主线程退出 2> 第一个新线程先打印“…

问题:编写程序完成如下功能:程序创建2个线程,然后:
        1> 主线程先打印“I am main thread”,然后睡眠2秒后,打印"main thread wake up",主线程退出
        2> 第一个新线程先打印“I am the first new thread”,然后睡眠3秒后,打印"the first new thread wake up",退出
        3> 第二个新线程先打印“I am the second new thread”,然后睡眠5秒后,打印"the fsecond new thread wake up",退出
    要求能看到所有打印信息



代码:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>void *fun1(){printf("I am the first new thread\n");sleep(3);printf("the first new thread wake up\n");return NULL;
}void *fun2(){printf("I am the second new thread\n");sleep(5);printf("the second new thread wake up\n");return NULL;
}int main(int argc,char *argv[]){pthread_t id[2];int ret = 0;ret = pthread_create(&id[0],NULL,fun1,NULL); // thread1ret += pthread_create(&id[1],NULL,fun2,NULL); // thread2if(ret){printf("pthread_create failed\n");return 1;}printf("I am main thread\n"); // main threadsleep(2);printf("main thread wake up\n");pthread_exit(NULL); // main thread exitpthread_join(id[0],NULL); // thread1 exitpthread_join(id[1],NULL); // thread2 exitreturn 0;
}

输出:

http://www.hkea.cn/news/538801/

相关文章:

  • 单位网站 单位网页 区别吗福州seo顾问
  • 专业做网站制作的公司百度地图网页版进入
  • 买卖网站域名骗局百度推广登陆
  • 石家庄大型网站设计公司手机怎么建网站
  • 政府网站图解怎么做百度关键词排名靠前
  • 天津做网站印标东莞网络推广排名
  • 设计一个外贸网站需要多少钱沈阳网站推广优化
  • 洗化行业做网站福州百度seo排名
  • 西安app网站开发项目腾讯域名注册官网
  • 网站开发的技术指标如何做网站搜索引擎优化
  • 建网站的要求老铁外链工具
  • wordpress有广告郑州seo优化大师
  • 企业网站推广的实验内容企业宣传网站
  • 如何开发高端市场宁波seo快速优化公司
  • 常用设计资源网站爱网站
  • 企业品牌网站营销关于seo的行业岗位有哪些
  • 群晖怎样做网站惠州网络营销
  • 怎么做网站内部链接的优化品牌营销推广代运营
  • 婚纱照网站制作搜索引擎优化搜索优化
  • 网站建设吉金手指专业13中国营销网站
  • 做销售在哪些网站注册好百度产品
  • dw做汽车网站seo排名工具提升流量
  • 网络培训学校排名奉化seo页面优化外包
  • vps除了做网站还能做什么晨阳seo服务
  • seo网站建设优化什么意思网络营销与直播电商专业就业前景
  • 工程建设企业网站网站关键词优化应该怎么做
  • 修复wordpress青岛网站优化
  • 敦煌网站做外贸怎样网页推广怎么做的
  • 南京网站建设优化今日头条普通版
  • 网站编辑的工作职能有哪些活动营销案例100例