It's not a secret anymore!
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "interrupt doesn Watch "interrupt doesn New topic

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".

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

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:
subject: interrupt doesn't interrupt?
It's not a secret anymore!