如何对一个阻塞的线程进行计时?比如阻塞5秒后自动结束线程?
学习是最好的投资!
Design a monitor thread to specifically monitor the execution time of other threads. Start timing, then check the thread status every 1 second
Thread.sleep(1000L * 5); return;
I don’t knowsleep whether it can meet the request of the questioner
sleep
General blocking methods can set a timeout and control it in the thread.
Design a monitor thread to specifically monitor the execution time of other threads. Start timing, then check the thread status every 1 second
I don’t know
sleep
whether it can meet the request of the questionerGeneral blocking methods can set a timeout and control it in the thread.