How to stop an std::thread from running, without terminating the program

前端 未结 3 1779
时光取名叫无心
时光取名叫无心 2020-12-17 05:44

I am trying to learn std::threads from C++11 to make a threading system.

I was wondering if there is a way to stop a thread from running (N

3条回答
  •  天涯浪人
    2020-12-17 06:11

    The C++ std::thread class is really just a minimal interface layered on top of some more complete implementation-defined threading package. As such, it only defines a tiny amount of functionality -- creating new threads, detach, and join. That's pretty much it -- there's no standard way of managing, scheduling, stopping/starting/killing threads or doing much else.

    There is a native_handle method that returns an implementation-defined type which can probably be used to do what you want, depending on the implementation.

提交回复
热议问题