jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic


Girish Nagaraj
Ranch Hand

Joined: Apr 19, 2006
Posts: 153
class A extends Thread {

public void run() {

try {

} catch (InterruptedException ie) {

System.out.println("Thread Interrupted");

System.out.println("\n" + interrupted());

class X {

public static void main(String[] args) {

A t = new A();

Thread Interrupted
false // Why false here

interrupted() resets interrupt flag right?

Thanks in Advance.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Each Thread has an associated boolean interruption status. Invoking t.interrupt for some Thread t sets t's interruption status to true, unless Thread t is engaged in Object.wait, Thread.sleep, or Thread.join; in this case interrupt causes these actions (in t) to throw InterruptedException, but t's interruption status is set to false.
Girish Nagaraj
Ranch Hand

Joined: Apr 19, 2006
Posts: 153
Thanks wise
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
hi wise
can you plz explain bit more


"Know where to find the solution and how to use it - that's the secret of success."
I agree. Here's the link: http://aspose.com/file-tools
subject: Threads
It's not a secret anymore!