Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
While it is possible to write a thread-safe program that stores all its state in public static fields, it is a lot harder to verify its thread safety or to modify it so that it remains thread-safe than one that uses encapsulation appropriately. Encapsulation makes it possible to determine that a class is thread-safe without having to examine the entire program.
|
The design process for a thread-safe class should include these three basic elements:
|