摘要: 对于一个存在多个线程的进程来说,有时候我们需要有一份数据是每个线程都拥有的,也就是说每个线程自己操作自己的这份数据,这有点类似 C++ 类的实例属性,每个实例对象操作的都是自己的属性。我们把这样的数据称之为线程局部存储(Thread Local Storage, TLS),对应的存储区域叫做线程局部 阅读全文
posted @ 2022-01-13 17:53 PanDai 阅读(55) 评论(0) 推荐(0)
摘要: #include <thread> #include <mutex> #include <condition_variable> #include <list> #include <iostream> class Task { public: Task(int taskID) { this->tas 阅读全文
posted @ 2022-01-13 14:29 PanDai 阅读(123) 评论(0) 推荐(0)
摘要: 1 #include <pthread.h> 2 #include <errno.h> 3 #include <unistd.h> 4 #include <list> 5 #include <semaphore.h> 6 #include <iostream> 7 class Task 8 { 9 阅读全文
posted @ 2022-01-13 11:10 PanDai 阅读(36) 评论(0) 推荐(0)
摘要: 1 #include <pthread.h> 2 #include <errno.h> 3 #include <unistd.h> 4 #include <list> 5 #include <semaphore.h> 6 #include <iostream> 7 class Task 8 { 9 阅读全文
posted @ 2022-01-13 10:18 PanDai 阅读(58) 评论(0) 推荐(0)