How to stop a running pthread thread?

前端 未结 4 703
庸人自扰
庸人自扰 2020-12-18 05:27

How can I exit or stop a thread immediately?

How can I make it stop immediately when the user enters an answer? I want it to reset for every question.

Here\

4条回答
  •  悲哀的现实
    2020-12-18 06:09

    You can simply call pthread_cancel on that thread to exit it. And you can send SIGSTOP/SIGCONT signal via pthread_kill to stop/restart it.


    But if all you want is a timer, why must you thread?

提交回复
热议问题