不用贴代码,赐我点儿思路就可以,我只会设置线程超时,但是底端上送心跳时这个线程应该是不受影响继续执行的,设置了超时时间,就算心跳上来了到了超时时间这个线程也没了,比较苦恼=。=
或者是否可以更新线程超时时间呢?每次心跳过来我都重新设置一个线程的超时时间
伊谢尔伦2017-04-18 09:18:17
Don’t use the idea of fixed timeout.
There is a dedicated thread to manage all threads and receive heartbeats. This thread naturally has the heartbeat information of all threads. It also naturally knows which thread has not received heartbeats for more than 5 seconds, and then sends messages to the threads that should be terminated in this thread. interrupt signal.
ringa_lee2017-04-18 09:18:17
The simple way is to set the read timeout directly. The second is to use non-blocking IO to implement communication, so that the timeout program can be done directly in the current thread.