2014年6月15日

线程同步机制之互斥锁通信机制

摘要: #include #include #include #include void *thread_function(void *arg);pthread_mutex_t work_mutex;#define WORK_SIZE 1024char work_area[WORK_SIZE];int ti... 阅读全文

posted @ 2014-06-15 17:35 lakeone 阅读(354) 评论(0) 推荐(0) 编辑

线程共享全局变量和私有全局变量

摘要: 共享全局变量实例:#include #include #include #include int key=100;void *helloworld_one(char *argc){ printf("the message is %s\n",argc); key=10; printf... 阅读全文

posted @ 2014-06-15 16:27 lakeone 阅读(2978) 评论(0) 推荐(0) 编辑

线程退出前操作

摘要: #include #include #include #include void cleanup(){ printf("cleanup\n");}void *test_cancel(void){ pthread_cleanup_push(cleanup,NULL); printf(... 阅读全文

posted @ 2014-06-15 11:47 lakeone 阅读(185) 评论(0) 推荐(0) 编辑

Linux下线程pid和tid

摘要: #include #include #include #include struct message{ int i; int j;};void *hello(struct message *str){ printf("child, the tid=%lu, pid=%d\n",pt... 阅读全文

posted @ 2014-06-15 09:29 lakeone 阅读(31597) 评论(0) 推荐(1) 编辑

导航