线程属性-分离
来源:互联网 发布:数据散修 编辑:程序博客网 时间:2024/05/24 03:33
#ifndef __IO_H__#define __IO_H__#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <fcntl.h>#include <unistd.h>#include <pthread.h>#endif#include "io.h"void* thread_fun(void* arg){ int i = 0; while (i++ < 10) { printf("i=%d\n", i); sleep(1); } pthread_exit((void*)0);}int main(int argc, char const *argv[]){ pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&th, &attr, thread_fun, NULL); /*pthread_attr_destroy(&attr);*/ int state; pthread_attr_getdetachstate(&attr, &state); if (state == PTHREAD_CREATE_DETACHED) { printf("set detach ok!\n"); } else { printf("set detach error!\n"); } if(pthread_join(th, NULL)){ fprintf(stderr, "join:success!%s\n", strerror(errno)); } pthread_attr_destroy(&attr); return 0;}
阅读全文
0 0
- 线程的分离属性
- 线程属性-分离
- 线程-属性分离2
- linux之线程属性(分离线程)
- 多线程编程-线程控制与属性(结合与分离)
- 分离线程
- 线程分离
- 分离线程
- 分离线程
- 线程分离
- Linux多线程编程之设置线程属性,设置线程分离属性
- 详解线程、了解进程与线程的区别以及线程分离与结合属性
- UNIX环境高级编程——线程属性之分离属性
- 学习pthreads,使用属性对象创建结合线程和分离线程
- 【Linux】线程(概念、特点、线程控制代码--创建/等待/终止、分离与结合属性)
- 线程的基本属性(分离,栈大小,保护区,竞争,调度并发)以及TSD特定数据
- 关于分离线程
- linux 分离线程
- Memcached
- java 设计模式--1
- Button自动刷新页面的问题
- 这张免费峰会门票你一定不想错过
- JVM学习笔记(三)—— 对象之死
- 线程属性-分离
- java7中的fork/join框架
- 欢迎使用CSDN-markdown编辑器
- 输入单个字符
- 自定义加载Dialog
- MySQL外部导入数据报错
- 如何让div获取焦点或可编辑
- Spring Boot 中使用MyBatis Mapper方式(xml)
- 用python中的列表实现名字管理系统