How to get std::thread of current thread?

前端 未结 3 399
忘掉有多难
忘掉有多难 2021-01-04 03:58

How can I get a std::thread object representing current (already running thread).

I know I can do std::this_thread::get_id(). However, this

3条回答
  •  别那么骄傲
    2021-01-04 04:39

    You can't get a std::thread object referring to a thread that wasn't created by the std::thread constructor. Either consistently use the C++ thread library, or don't use it at all. If the current thread was created by pthread_create, for example, it will need to be joined to using pthread_join.

提交回复
热议问题