Concurrent Programming in Java
© 1996-1999 Doug Lea  

 

 


3.1 Dealing with Failure

Follow-ups

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: 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: A resource control framework is described in:


Doug Lea
Last modified: Sun Oct 17 07:53:28 EDT 1999