search

Home  >  Q&A  >  body text

Java线程阻塞计时

如何对一个阻塞的线程进行计时?比如阻塞5秒后自动结束线程?

PHPzPHPz2893 days ago405

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:47:07

    Design a monitor thread to specifically monitor the execution time of other threads. Start timing, then check the thread status every 1 second

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:47:07

    Thread.sleep(1000L * 5);
    return;
    

    I don’t knowsleep whether it can meet the request of the questioner

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:47:07

    General blocking methods can set a timeout and control it in the thread.

    reply
    0
  • Cancelreply