Package VASSAL.tools.concurrent
Class QueueJoiner
java.lang.Object
VASSAL.tools.concurrent.QueueJoiner
public class QueueJoiner extends Object implements Callable<Void>
A
Callable which calls a Callable retrieved from a queue.
QueueJoiner permits one queue of Callables to be joined
into a single Callable and inserted into another queue. One reason
for doing this is to make a single queue of Callables available
from multiple threads. E.g., if a task run by an ExecutorService
needs to submit other tasks to the same ExecutorService, those
child tasks ey can be queued and submitted via a QueueJoiner, while
the original task can work on the same queue using a second
QueueJoiner. This prevents the ExecutorService from
deadlocking in the event that the child tasks are unable to make it to the
front of the ExecutorService's queue, because the thread of the
original task will eventually clear the queue on its own.- Since:
- 3.1.11
- Author:
- Joel Uckelman
-
Field Summary
Fields Modifier and Type Field Description protected BlockingQueue<? extends Callable<?>>queue -
Constructor Summary
Constructors Constructor Description QueueJoiner(BlockingQueue<? extends Callable<?>> queue)Creates aCallablewhich calls aCallableretrieved from a queue. -
Method Summary
-
Field Details
-
queue
-
-
Constructor Details
-
QueueJoiner
Creates aCallablewhich calls aCallableretrieved from a queue.- Parameters:
queue- the queue
-
-
Method Details