An even weaker idea is to create read-only wrappers for existing objects. The later can be strengthened by using in with the clone method. The following two slides illustrate read-only objects. We may needs different versions of a data structure that works differently if it is uses sequentially or with threads. On this slide, we have a Stack that is not synchronized for use in sequential programming.
Composition is used over inheritance.
Since we may need a LinkedListStack class, composition will allow the SynchronizedStack and the WaitingStack to work with LinkedListStack objects. This example provides straightforward synchronization for a Stack object. The stack below does this. When these operations are done then another thread will use the result of the computations. The polling done here does consume CPU cycles.