jQuery in Action, 2nd edition
The moose likes Threads and Synchronization and the fly likes How to stop a thread that is waiting for input? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "How to stop a thread that is waiting for input?" Watch "How to stop a thread that is waiting for input?" New topic
Author

How to stop a thread that is waiting for input?

Andrew Lit
Ranch Hand

Joined: Jul 01, 2002
Posts: 135
Hi,
this is a console program
thank you in advance
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
If your inter-thread communication uses the wait()/notify() mechanism, -- you can do just that, -- notify the waiting thread so that it can resume. If the thread in question contains a while loop as part of its run() method, you can set a boolean to terminate to exit from that loop.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24051
    
  13

I think his real question is "How can you interrupt a call to System.in.read()?" Unfortunately, I don't know the answer: interrupt() doesn't work.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to stop a thread that is waiting for input?