participate


Java Programming [Archive] - how to interrupt BufferedReader.readLine() ?
<<   Back to Forum  |   Give us Feedback
This topic has 1 reply on 1 page.
TomBaeyens
Posts:4
Registered: 3/12/01
how to interrupt BufferedReader.readLine() ?   
Jun 1, 2005 4:18 AM

 
i'm using jdk 1.4.2_03-b02

thread 'reader' is reading input with BufferedReader.readLine(); now another thread wants to stop the 'reader' thread.

javadoc of Thread says that the best approach is to set a boolean and call Thread.interrupt() but no luck. BufferedReader.readLine() keeps waiting.

i tried various alternatives, but no luck. found on some other forum that it is impossible to interrupt this call. i can't believe that :-)

any pointers are appreciated.

regards, tom.
 
-Kayaman-
Posts:3,256
Registered: 8/13/03
Re: how to interrupt BufferedReader.readLine() ?   
Jun 1, 2005 4:23 AM (reply 1 of 1)  (In reply to original post )

 
You need to modify your design, if you start reading and there's nothing to read, it will block until new data is available. You can get around this possibly with the NIO api.

What are you trying to do anyway? Where does the data come from?
 
This topic has 1 reply on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 129

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums