关闭curent线程C ++

时间:2014-10-19 18:01:19

标签: c++ multithreading

编辑。

如何在类方法中关闭(永久停止)当前线程?

现在,我有:

methodName() {
    std::unique_lock<std::mutex> locker(...);
    cv.wait(locker, [this]{return ready_ || finished_;});
    if (finished_) //need to terminate cur thread
    ...
}

1 个答案:

答案 0 :(得分:1)

问题不是那么清楚,但如果您正在使用Windows,则无法使用TerminateThread关闭任何线程,或者如果要关闭当前线程,则可以使用CloseThread。< / p>