public class ProducerConsumerQueue<T> extends Object
Constructor and Description |
---|
ProducerConsumerQueue(int producersToWaitFor) |
ProducerConsumerQueue(int queueLength,
int producersToWaitFor) |
Modifier and Type | Method and Description |
---|---|
void |
producerStopping()
Each producer thread should call producerStopping() when it has
finished.
|
void |
put(T obj)
Adds a new object to the queue, blocking if no space is
available.
|
T |
take()
Blocks until an object is available; when null
is returned the client thread should quit.
|
public ProducerConsumerQueue(int producersToWaitFor)
producersToWaitFor
- The number of producer threads.public ProducerConsumerQueue(int queueLength, int producersToWaitFor)
public T take() throws InterruptedException
InterruptedException
- if interrupted while waitingpublic void put(T obj) throws InterruptedException
obj
- the object to add to the queueInterruptedException
- if interrupted while waitingpublic void producerStopping()
Copyright © 2016 JBoss by Red Hat. All rights reserved.