| ||||
Copyright 1999 Sams Publishing |
|
Chapter 15: Breaking Out of a Blocked I/O State |
Overview |
Unfortunately, as of Java 1.2, most blocking I/O statements in the JDK still ignore interrupt requests . This presents a problem when you want to have a thread stop waiting on the I/O operation and do something elsetypically to clean up and die. This problem generally arises in situations where data is read from a stream intermittently. A common case is a conversation between a client and server over a sockets streams. Typically in this scenario, a thread blocks for long periods of time on a stream waiting for another request to come across the line. |
In this chapter, Ill present some techniques that you can use to get a thread to break out of a blocked I/O state. Ill begin by demonstrating the blocking problem with an example. |
| |||
Toc |