23 |
|
* to swap buffers between threads so that the thread filling the |
24 |
|
* buffer gets a freshly emptied one when it needs it, handing off the |
25 |
|
* filled one to the thread emptying the buffer. |
26 |
< |
* <pre>{@code |
26 |
> |
* <pre> {@code |
27 |
|
* class FillAndEmpty { |
28 |
|
* Exchanger<DataBuffer> exchanger = new Exchanger<DataBuffer>(); |
29 |
|
* DataBuffer initialEmptyBuffer = ... a made-up type |
59 |
|
* new Thread(new FillingLoop()).start(); |
60 |
|
* new Thread(new EmptyingLoop()).start(); |
61 |
|
* } |
62 |
< |
* } |
63 |
< |
* }</pre> |
62 |
> |
* }}</pre> |
63 |
|
* |
64 |
|
* <p>Memory consistency effects: For each pair of threads that |
65 |
|
* successfully exchange objects via an {@code Exchanger}, actions |