摘要: 子线程循环10次,接着主线程循环100次,接着又回到子线程循环10次,接着再回到主线程又循环100次,如此循环50次,试写出代码。#include #include #include #include pthread_attr_t attr;pthread_mutex_t mutex;pthre... 阅读全文
posted @ 2014-09-22 22:58 辰‘心’闪烁 阅读(564) 评论(0) 推荐(0) 编辑
摘要: 1.线程属性线程具有属性,用pthread_attr_t表示,在对该结构进行处理之前必须进行初始化,在使用后需要对其去除初始化。我们用pthread_attr_init函数对其初始化,用pthread_attr_destroy对其去除初始化。1.名称::pthread_attr_init/pthre... 阅读全文
posted @ 2014-09-22 22:54 辰‘心’闪烁 阅读(426) 评论(0) 推荐(0) 编辑
摘要: pthread_cond_wait()用于阻塞当前线程,等待别的线程使用pthread_cond_signal()或pthread_cond_broadcast来唤醒它。pthread_cond_wait()必须与pthread_mutex 配套使用。pthread_cond_wait()函数一... 阅读全文
posted @ 2014-09-22 22:52 辰‘心’闪烁 阅读(264) 评论(0) 推荐(0) 编辑