This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.



Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

interrupting System.in.read(byte[ ])  RSS feed

 
Jack Wiesenthaler
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume I have the following blocking I/O call in a thread:
byte b[] = new byte[255];
try
{
System.in.read(b);
}
catch(IOException _ex)
{}
If I want to immediately unblock the I/O call from the main thread after a timeout period with Thread.interrupt() how would I do it? It seems Thread.interrupt() does not unblock InputStream.read()!
I tried closing the InputStream with System.in.close() as suggested by some people but that throws an exception only **after** the ENTER key is pressed which is useless.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!