Java Reference
In-Depth Information
PublishingVehicleTracker
derives its thread safety from delegation to an underly-
ing
ConcurrentHashMap
, but this time the contents of the
Map
are thread-safe mutable
points rather than immutable ones. The
getLocation
method returns an unmodifiable
copy of the underlying
Map
. Callers cannot add or remove vehicles, but could change the loc-
ation of one of the vehicles by mutating the
SafePoint
values in the returned
Map
. Again,
the “live” nature of the
Map
may be a benefit or a drawback, depending on the requirements.
PublishingVehicleTracker
is thread-safe, but would not be so if it imposed any ad-