What is the best method to get objects out of a BlockingQueue, in a concurrent program, without hitting a race condition? I'm currently doing the following and I'm not convinced ... |
I have a class that takes objects from a BlockingQueue and processes them by calling take() in a continuous loop. At some point I know that no more objects will ... |
BlockingQueue has the method called drainTo() method but it is not blocked. I need a blocking queue that I want to blocked but also able to retrieve queued-object in a ... |
Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing them.
public void scheduleTask(int delay, TimeUnit timeUnit)
{
scheduledExecutorService.scheduleWithFixedDelay(new Task(queue), 0, delay, timeUnit);
}
How can I schedule ... |
I'm wrestling with the best way to implement my processing pipeline.
My producers feed work to a BlockingQueue. On the consumer side, I poll the queue, wrap what I get in ... |
I have some code where i execute a several tasks using Executors and a Blocking Queue. The results have to be returned as an iterator because that is what the application ... |
Consider a BlockingQueue and a few threads waiting on poll(long, TimeUnit) (possibly also on on take()).
Now the queue is empty and it is desired to notify the waiting threads that they ... |
|
I'm trying to use a ThreadPoolExecutor to schedule tasks, but running into some problems with its policies. Here's its stated behavior:
- If fewer than corePoolSize threads are running, the Executor always prefers ...
|
For a single producer-consumer arrangement the producer places a 'done signal' as the last item on the queue.
The consumer checks each object taken from the queue and shuts down when ... |
I see these implementation of BlockingQueue and can't understand the differences between them. My conclusion so far:
- I won't ever need SynchronousQueue
- LinkedBlockingQueue ensures FIFO, BlockingQueue must be created with parameter true to ...
|
I am refreshing my memory about Java concurrency and I was playing around with the popular producer consumer problem. I have implemented the below code which works correctly if there is ... |
The JavaDoc for ThreadPoolExecutor is unclear on whether it is acceptable to add tasks directly to the BlockingQueue backing the executor. The docs say calling executor.getQueue() is "intended primarily ... |
I have this piece of code. A LinkedBlockingQueue should only throw an Exception if interrupted while waiting to add to the queue. But this queue is unbounded so it should add ... |
I was trying to use the iterator methods on a BlockingQueue and discovered that hasNext() is non-blocking - i.e. it will not wait until more elements are added and will instead ... |
So I am using a fixed sized BlockingQueue [ArrayBlockingQueue] in a producer/consumer type application, but I want the user to be able to change the queue size on the fly. ... |
In this simple short program, you will notice that the program hangs forever because the take() does not release the thread. According to my understanding, take() causes the thread to be ... |
I know that concurrent adds to an stl queue in c++ can cause issues, and the way to solve this is adding a mutex lock around all add/remove calls.
But I ... |
I have an application that creates hundreds of instances of some objects B and C.
There is an object hierarchy where object Foo contains 2 queues (b_queue and c_queue), one filled with ... |
I am a little bit confused as to what the difference is between BlockingQueue/LinkedBlockingQueue and the new TransferQueue/LinkedTransferQueue types from jsr166y and java 7
|
I need an Object to be asynchronously notified when some BlockingQueue has got an item to give.
I've searched both Javadoc and the web for a pre-made solution, then I ended up ... |
I've implemented a pipeline approach. I'm going to traverse a tree and I need certain values which aren't available beforehand... so I have to traverse the tree in parallel (or before) ... |
I have need for a LinkedBlockingQueue but what I am passing primitives to it. My data rates for adding to the Queue are about 4ms or 256 data points per ... |
Is there already some existing JUnit test for testing a BlockingQueue interface? Some class I can download, press play and then it turns red (hopefully green :-)), without me having to ... |