In an aside to his running series on programming Java threads in the real world, Allen prefaces this month's column with a look at one dangerous new "feature" of the Java 2 platform: the ability to produce noncompliant class files that will not run on a 1.1 Java virtual machine (JVM). From there, he picks up the theme from Part 4 of this series. This month's main topic is timers, both the one in the Swing library (called Timer) and also a roll-your-own variety called Alarm, which is useful when the Swing Timer isn't available or appropriate. Timers let you perform fixed-interval operations, such as animation refreshes. The Alarm implementation included here is by far the most complicated of the classes you've looked at so far, and it demonstrates several important Java programming techniques, such as how to write code that needs to suspend and resume threads without using the (now deprecated) suspend() and resume() methods. Along the way, Allen reveals how to kill a thread gracefully, without using the (also deprecated) stop() method. (6,000 words)
3. Programming Java threads in the real world, Part 6
This month continues the thread theme by examining how to implement the Observer pattern (used by AWT/Swing for its event model) in a multithreaded environment. The article covers how to notify observers in an efficient, thread-safe way using code modeled after Java's AWTEventMulticaster. It also considers a few problems with AWT/Swing's use of Observer. (4,500 words)
With MutableThread and ThreadWatchDog, you can make your threads come back to life and continue running seamlessly even after thread death. (1,400 words; November 15, 2002)