Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Threads
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Threads and Synchronization
interrupt doesn't interrupt?
Rebecca Witmer
Ranch Hand
Posts: 46
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 1646
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
From the JavaDocs for Thread.interrupt():
If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then [I]its interrupt status will be cleared[/I] and it will receive an InterruptedException. [ My emphasis ]
Is that Thread currently sleeping or waiting?
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
interrupting a thread
stopping a thread
Interrrupted()--concept.....
Thread again..
interruption in thread
More...