blockingqueue « concurrency « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » concurrency » blockingqueue 

1. Best method to get objects from a BlockingQueue in a concurrent program?    stackoverflow.com

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 ...

2. How to interrupt a BlockingQueue which is blocking on take()?    stackoverflow.com

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 ...

3. BlockingQueue - blocked drainTo() methods    stackoverflow.com

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 ...

4. ScheduledExecutorService with variable delay    stackoverflow.com

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 ...

5. producer/consumer work queues    stackoverflow.com

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 ...

6. how to terminate retrieval from a blocking queue    stackoverflow.com

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 ...

7. How to immediately release threads waiting on a BlockingQueue    stackoverflow.com

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 ...

8. ThreadPoolExecutor policy    stackoverflow.com

I'm trying to use a ThreadPoolExecutor to schedule tasks, but running into some problems with its policies. Here's its stated behavior:

  1. If fewer than corePoolSize threads are running, the Executor always prefers ...

9. How do you fashion a stop condition for multiple consumers using a Java 1.5 BlockingQueue?    stackoverflow.com

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 ...

10. Implementation of BlockingQueue: What are the differences between SynchronousQueue and LinkedBlockingQueue    stackoverflow.com

I see these implementation of BlockingQueue and can't understand the differences between them. My conclusion so far:

  1. I won't ever need SynchronousQueue
  2. LinkedBlockingQueue ensures FIFO, BlockingQueue must be created with parameter true to ...

11. Multiple Producers and consumers problem in Java (Without BlockingQueue)    stackoverflow.com

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 ...

12. Is adding tasks to BlockingQueue of ThreadPoolExecutor advisable?    stackoverflow.com

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 ...

13. LinkedBlockingQueue thowing InterruptedException    stackoverflow.com

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 ...

14. Why does the iterator.hasNext not work with BlockingQueue?    stackoverflow.com

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 ...

15. Re-sizeable Java BlockingQueue    stackoverflow.com

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. ...

16. Why is BlockingQueue.take() not releasing the thread?    stackoverflow.com

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 ...

17. Concurrent put calls on a BlockingQueue in Java    stackoverflow.com

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 ...

18. Java: Concurrently removing objects from queues.    stackoverflow.com

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 ...

19. Difference between BlockingQueue and TransferQueue    stackoverflow.com

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

20. Being asynchronously notified of a BlockingQueue having an item available    stackoverflow.com

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 ...

21. concurrent application not as fast as a singlethreaded    stackoverflow.com

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) ...

22. LinkedBlockingQueue and primitives    stackoverflow.com

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 ...

23. JUnit test for BlockingQueue interface    stackoverflow.com

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 ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.