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

酒类公司网站模板公司名称大全好听

酒类公司网站模板,公司名称大全好听,代理注册公司注意什么,高校档案网站建设的目的是什么意思pthread_exit#xff1a; 在线程中禁止调用exit函数#xff0c;否则会导致整个进程退出#xff0c;取而代之的是调用pthread_exit函数#xff0c;这个函数只会使一个线程退出#xff0c;如果主线程使用pthread_exit函数也不会使整个进程退出#xff0c;不会影响其他线程…pthread_exit 在线程中禁止调用exit函数否则会导致整个进程退出取而代之的是调用pthread_exit函数这个函数只会使一个线程退出如果主线程使用pthread_exit函数也不会使整个进程退出不会影响其他线程的执行 函数原型void pthread_exit(void *retval); 函数参数retval通常传NULL 注意pthread_exit或者return返回的指针所指向的内存单元必须是全局的或者使用nalloc分配的不能在线程函数的栈上分配因为当其他线程得到这个返回指针时这个线程函数已经退出了栈空间会被回收 通过以下代码我们可以发现子线程执行exit会让整个进程结束。 #includestdio.h #includestdlib.h #includestring.h #includesys/types.h #includeunistd.h #include pthread.h void *mythread(void *arg) {printf(child thread,pid[%d],id[%ld]\n,getpid(),pthread_self());exit(0); } int main() {//int pthread_create(pthread_t *thread, const pthread_attr_t *attr,// void *(*start_routine) (void *), void *arg);pthread_t thread;int retpthread_create(thread,NULL,mythread,NULL);if(ret!0){printf(pthread_create error:[%s]\n,strerror(ret));return -1;}sleep(1);//让子线程先执行printf(father thread,pid[%d],id[%ld]\n,getpid(),pthread_self()); } 可以发现主线程并没有执行 通过以下代码可以发现主线程执行pthread_exit函数后子线程还可以执行   #includestdio.h #includestdlib.h #includestring.h #includesys/types.h #includeunistd.h #include pthread.h void *mythread(void *arg) {sleep(1);//保证主线程先执行printf(child thread,pid[%d],id[%ld]\n,getpid(),pthread_self()); } int main() {//int pthread_create(pthread_t *thread, const pthread_attr_t *attr,// void *(*start_routine) (void *), void *arg);pthread_t thread;int retpthread_create(thread,NULL,mythread,NULL);if(ret!0){printf(pthread_create error:[%s]\n,strerror(ret));return -1;}printf(father thread,pid[%d],id[%ld]\n,getpid(),pthread_self());pthread_exit(NULL); }pthread_join函数 函数作用阻塞等待线程退出获取线程退出状态。其作用跟进程的waitpid函数相似 函数原型int pthread_join(pthread_t thread, void **retval); 函数返回值 成功返回0失败返回错误号 函数参数 thread:线程id retval:存储线程结束状态整个指针和pthread_exit的参数是同一块内存地址  #includestdio.h #includestdlib.h #includestring.h #includesys/types.h #includeunistd.h #include pthread.h void *mythread(void *arg) {int *p(int *)malloc(sizeof(int));或者用全局变量*p9;printf(child thread,id[%ld],add[%p]\n,pthread_self(),p);pthread_exit(p); } int main() {//int pthread_create(pthread_t *thread, const pthread_attr_t *attr,// void *(*start_routine) (void *), void *arg);pthread_t thread;int retpthread_create(thread,NULL,mythread,NULL);if(ret!0){printf(pthread_create error:[%s]\n,strerror(ret));return -1;}// int pthread_join(pthread_t thread, void **retval);void *ptmalloc(sizeof(void));pthread_join(thread,pt);int n*(int *)pt;printf(child exit status:[%d],add[%p]\n,n,pt); } 可以发现p和pt的地址是一样的 pt存储了线程结束状态
http://www.pierceye.com/news/477502/

相关文章:

  • 网站后台关键词交流建设网站
  • 学院网站建设总结华北理工大学学科建设处网站
  • 简单的网站php开发教程用cms做的网站 的步骤
  • seo杭州seo快速排名利器
  • 谷歌不收录网站一个完整的短视频策划方案
  • 网页制作培训网站关于营销的最新的新闻
  • 免费查找资料的网站wordpress中文4.8
  • 凡科建设的网站如何中式建筑公司网站
  • 珠海网站建设品牌策划开发设计公司网站
  • 找别人做的网站怎样修改招聘app
  • 学校网站内容建设银行网站电脑上不去
  • 住建部工程建设标准网站上海室内设计事务所
  • 做外贸采购都是用什么网站网站重构方案
  • 企业网站做推广河南app开发
  • 海宁做网站的公司仿搜狐视频网站源码
  • 网站备案和不备案的上海制作网站公司网站
  • 网站建设专业介绍在线平面图设计
  • 临时工找工作网站做美缝手机网站不收录
  • 凡科建站怎么样网络推广网站培训班
  • 优惠券的网站怎么做的网站建设业务元提成
  • 网站开发项目组成员免费建网站的app
  • 怎样自己做公司网站驻马店logo设计公司
  • 知名网站制作公司排名徐州人才网最新招聘2023
  • 网站建设与网页设计难学吗做彩票的网站
  • 请问怎么做网站郑州小程序开发制作
  • 城乡建设网站职业查询系统小公司根本办不了icp许可证
  • 网站架构搭建搭建网站是什么专业
  • 互助网站建设电脑做网站端口映射
  • 电力行业做的好的招投标网站wordpress 自定义注册表单
  • 网站开发采集工具网站设计计划书的要求