Why and when shouldn't I kill a thread?

后端 未结 6 843
陌清茗
陌清茗 2020-12-15 13:35

I am writing a multithreaded socket server and I need to know for sure.

Articles about threads say that I should wait for the thread to return, instead of killing it

6条回答
  •  无人及你
    2020-12-15 13:43

    In the case of a thread blocked in I/O you never really need to kill it, instead you have the choice between non-blocking I/O, timeouts, and closing the socket from another thread. Either of these will unblock the thread.

提交回复
热议问题