aspose file tools*
The moose likes Threads and Synchronization and the fly likes interrupt doesn't interrupt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "interrupt doesn Watch "interrupt doesn New topic
Author

interrupt doesn't interrupt?

Rebecca Witmer
Ranch Hand

Joined: Sep 10, 2004
Posts: 46
I have the following small method in my code. spt is a thread. Why doesn't isInterrupted() always return true? It always prints "false".
Rebecca

public void stopSegment( ) {
if (segmentPlaying){
segmentTimer.stop( );
segmentLine.stop();
segmentLine.flush();
segmentLine.close();

spt.interrupt();
boolean interrupted = spt.isInterrupted();
spt = null;
System.out.println("Spt is interrupted is " + interrupted);

segmentPlaying = false;
}
}


SCJP 1.4
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
From the JavaDocs for Thread.interrupt():Is that Thread currently sleeping or waiting?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interrupt doesn't interrupt?