Concurrent Programming in Java
© 1996-1999 Doug Lea
3.1 Dealing with Failure
The caveats in the book about interruptions and interrupted IO should
be made stronger for recent JDK releases. Interruptions and java.io
increasingly do not mix well. However, as of JDK1.4, any concurrent
program that needs interruptibility during IO should be using the
java.nio package, which explicitly supports interruptible IO.
In particular, the code example on p173 illustrating workarounds using
available has many limitations, among them not being able to
distinguish EOFs from blocked reads. There are no good soluitions to
this using only java.io, but these matters become straightforward
using java.nio. (Thanks to Jim Yingst for pointing out problems.)
Readings and Resources
A pattern-based account of exception handling may be found in:
Some low-level techniques for protecting code from asynchronous
cancellation or interruption (e.g., masking hardware interrupts) are
not available or appropriate in the Java programming language. But
even many systems-level developers avoid asynchronous cancellation
at all costs. See for example Butenhof's book listed in §1.2.5. Similar concerns are expressed about
concurrent object-oriented programs in:
Renzel, Klaus. "Error Detection", in Frank Buschmann and Dirk
Riehle (eds.) Proceedings of the 1997 European Pattern Languages
of Programming Conference, Irsee, Germany, Siemens Technical
Report 120/SW1/FB, 1997.
Detecting and responding to termination of a group of threads can
require more complex protocols when applied in less structured
contexts than seen in most concurrent programs. General-purpose
termination detection algorithms are discussed in several of the
sources on concurrent and distributed programming listed in §1.2.5.
Security management is described in:
Fleiner, Claudio, Jerry Feldman, and David Stoutamire. "Killing
Threads Considered Dangerous", Proceedings of the POOMA '96
A resource control framework is described in:
Gong, Li. Inside JavaTM 2 Platform Security, Addison-Wesley, 1999.
Czajkowski, Grzegorz, and Thorsten von Eicken. "JRes: A Resource
Accounting Interface for Java", Proceedings of 1998 ACM OOPSLA
Conference, ACM, 1998.
Last modified: Sun Oct 17 07:53:28 EDT 1999