my dog learned polymorphism*
The moose likes Threads and Synchronization and the fly likes What causes a thread to be interrupted? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "What causes a thread to be interrupted?" Watch "What causes a thread to be interrupted?" New topic

What causes a thread to be interrupted?

Kjeld Sigtermans
Ranch Hand

Joined: Aug 10, 2006
Posts: 122

When running my code, at some point an InterruptedException is thrown during the execution of a Thread.sleep(...) instruction.
I have not explicitly interrupted the thread. I understand a thread is interrupted when its interrupt() method is called.
The big question is: what has caused my thread to be interrupted during its peaceful nap. Iow what can cause a thread to be interrupted? In this case, who has interrupted my thread?


Kjeld Sigtermans - SCJP 1.4 - SCWCD 1.4
Lester Burnham

Joined: Oct 14, 2008
Posts: 1337
The stack trace of the InterruptedException may give it a clue where it originated.
I agree. Here's the link:
subject: What causes a thread to be interrupted?
Similar Threads
Thread interruption does not work with netscape?
plz explain me interrupt(), isInterrupted(), interrupted() method
Database Thread Safety, pls review
How to indicate to JVM in code where is/is not a good place to kill my thread
BigInteger & Multithreading