最近学习asio全是boost库的内容:
比如shared_ptr、thread等等。
现在需要通过boost库获取threadid,可以参考下面代码:
unsigned long getThreadId()
{
std::string threadId=boost::lexical_cast<std::string>(boost::this_thread::get_id());
unsigned long threadNumber=0;
threadNumber =std::stoul(threadId,nullptr,16);
return threadNumber;
}
参考:http://stackoverflow.com/questions/4548395/how-to-retrieve-the-thread-id-from-a-boostthread
本文介绍了如何利用Boost库中的boost::this_thread::get_id()函数来获取当前线程的ID,并通过转换将线程ID从字符串形式转换为unsigned long类型。
410

被折叠的 条评论
为什么被折叠?



