It's not a secret anymore!*
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 Murach's Java Servlets and JSP this week in the Servlets 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
Database Thread Safety, pls review
plz explain me interrupt(), isInterrupted(), interrupted() method
Thread interruption does not work with netscape?
BigInteger & Multithreading
How to indicate to JVM in code where is/is not a good place to kill my thread