Java Reference
In-Depth Information
Listing 16.2. Inner class of FutureTask illustrating synchronization piggybacking.
We call this technique “piggybacking” because it uses an existing happensbefore ordering
that was created for some other reason to ensure the visibility of object X , rather than creating
a happens-before ordering specifically for publishing X .
Piggybacking of the sort employed by FutureTask is quite fragile and should not be un-
dertaken casually. However, in some cases piggybacking is perfectly reasonable, such as
when a class commits to a happens-before ordering between methods as part of its specific-
ation. For example, safe publication using a BlockingQueue is a form of piggybacking.
Search WWH ::




Custom Search