[英]Multithreaded C++ Program Not Running In Parallel Using vector<thread> and .join()
[英]In a multithreaded c++ program using boost, is there any way to get a pointer to the current thread?
我需要知道当前线程的身份,以跟踪哪些线程正在对共享数据结构发出某些请求。
您可以使用boost::this_thread::get_id()
获得代表线程的boost::thread::id
。
我认为您无法获得指向boost::thread
对象的指针,因为该线程不一定要附加一个。 它不能制造一个,因为它可能有一个附属。
没办法,但是您可以支持成对的hashmap:thread-id线程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.