nirma
asked on
TimeOut in Inputstream
Hi, I am looking for an efficient implementation of InputStream whit timeout, like in sockets
The constructor of this Inputstream should get a timeout parameter
The read method should throw IOException if waiting on read exceeds this timeout.
The constructor of this Inputstream should get a timeout parameter
The read method should throw IOException if waiting on read exceeds this timeout.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One problem may be that many IO call will block, and cannot be interrupted making it difficult to achieve what you require.
Can I ask why you need this?
Can I ask why you need this?
Normally - you should do this by starting a thread that reads the data. The main thread will start the it and sleep for the period of the timeout (for example using 'this.sleep(timeout)'. If the second thread reads data - it will notify the first thread about this - for example 'mainThread.notify()'