1217
2016-12-17 18:52
155 查看
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
struct menber
{
int a;
char *b;
}temp={8,"zieckey"};
void *create(void *arg)
{
printf("new thread ... \n");
return (void *)&temp;
}
int main(int argc,char *argv[])
{
int error;
pthread_t tid;
struct menber *c;
error = pthread_create(&tid, NULL, create, NULL);
if( error )
{
printf("new thread is not created ... \n");
return -1;
}
printf("main ... \n");
error = pthread_join(tid,(void *)&c);
if( error )
{
printf("new thread is not exit ... \n");
return -2;
}
printf("c->a = %d \n",c->a);
printf("c->b = %s \n",c->b);
sleep(1);
return 0;
}
#include <pthread.h>
#include <unistd.h>
struct menber
{
int a;
char *b;
}temp={8,"zieckey"};
void *create(void *arg)
{
printf("new thread ... \n");
return (void *)&temp;
}
int main(int argc,char *argv[])
{
int error;
pthread_t tid;
struct menber *c;
error = pthread_create(&tid, NULL, create, NULL);
if( error )
{
printf("new thread is not created ... \n");
return -1;
}
printf("main ... \n");
error = pthread_join(tid,(void *)&c);
if( error )
{
printf("new thread is not exit ... \n");
return -2;
}
printf("c->a = %d \n",c->a);
printf("c->b = %s \n",c->b);
sleep(1);
return 0;
}
相关文章推荐
- SpringBoot集成mybatis
- 预装Windows 10的电脑改装成 Win7 系统的参考教程
- ListView不同Item的适配详解
- 1071.新年趣事之打牌
- XenServer创建存储的方法
- SpringBoot配置属性之MQ
- POJ 1486 Sorting Slides 已翻译
- 视觉与应用
- ANdroid Studio中教你创建代码块---(续)
- tomcat 项目部署方法
- mfs
- Hibernate 批量删除 批量 插入 关联查询
- 第十六周项目3-归并排序算法的排序
- 选手及评委素材信息规范处理说明
- 杰瑞教育Android项目实训整理
- httpclient SocketTimeout ConnectTimeout ConnectionRequestTimeout
- 麻辣烫与安卓主线程工作原理
- 静态顺序表的基本操作
- 如何修改codeblocks主题
- java网络编程(四)