Java Reference
In-Depth Information
For example, it would be safe to publish mouseListeners or keyListeners in Visu-
alComponent . Because VisualComponent does not impose any constraints on the val-
id states of its listener lists, these fields could be made public or otherwise published without
compromising thread safety.
4.3.5. Example: Vehicle Tracker that Publishes Its State
Let's construct another version of the vehicle tracker that publishes its underlying mutable
state. Again, we need to modify the interface a little bit to accommodate this change, this
time using mutable but thread-safe points.
Listing 4.11. Thread-safe Mutable Point Class.
Search WWH ::




Custom Search