![](/img/trans.png)
[英]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.