|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
tcl.lang.ManagedSystemInStream
public class ManagedSystemInStream
A class for managing the System.in. Avoids blocking the current thread on the non-interruptible System.in.read(), by isolating all System.in.read()'s in a separate thread. Allows other classes to use System.in in a coordinated way, so that one class doesn't block access to System.in. After the initial instance is created, Java objects can read from System.in directly to get the benefits of this class, or can create another instance of this class that can be close()'d to interrupt a blocked read. This class forces standard input to remain unbuffered, so the JVM doesn't steal bytes from stdin that might be useful to subsequent processes that run after this JVM exits.
Constructor Summary | |
---|---|
ManagedSystemInStream()
Create a new ManagedSystemInStream. |
Method Summary | |
---|---|
int |
available()
|
void |
close()
Closes this ManagedSystemInStream instance. |
void |
dispose()
Signal readThread to stop, restore original stdin |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int offset,
int length)
|
void |
run()
Reads from System.in directly in a separate thread. |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ManagedSystemInStream()
Method Detail |
---|
public void dispose()
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int offset, int length) throws IOException
read
in class InputStream
IOException
public void run()
run
in interface Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |