What kind of behaviour causes an interrupted exception?

后端 未结 7 764
说谎
说谎 2020-12-24 13:15

I\'m relatively new to Threading in Java and I\'ve noticed that everytime I use Thread.sleep() I have to catch InterrupetdException.

What kind of behaviour causes th

7条回答
  •  执念已碎
    2020-12-24 13:40

    From the javadocs:

    Class InterruptedException

    Thrown when a thread is waiting, sleeping, or otherwise paused for a long time and another thread interrupts it using the interrupt method in class Thread.

    Hope that answers your question.

提交回复
热议问题