Questions tagged [blockingqueue]

A queue data structure that that waits (suspends the current thread) for the queue to become non-empty when retrieving an element and for space to become available in the queue when storing an element.

A queue data structure that waits (suspends the current thread) for the queue to become non-empty when retrieving an element, or for space to become available in the queue when storing an element.

References

458 questions
2
votes
2 answers

Correct way to access a queue (LinkedBlockingQueue) from ExecutorService

I have just realised LinkedBlockingQueue is a good solution in my case - I have a queue which is filled from time to time (but in very short time intervals). I want my ExecutorService to check as often as posiible for any objects appearing in this…
Marta Karas
  • 4,967
  • 10
  • 47
  • 77
2
votes
2 answers

Android threads with queue vs Handler/Looper: which one is efficient?

I have a producer-consumer situation, where I want to decide between two mechanisms to implement it. It is an audio-recording/encoding case: The producer polls device microphone ,continuously, for the recorded audio, and when an audio sample is…
Nazar Merza
  • 3,365
  • 1
  • 19
  • 19
2
votes
2 answers

C++ Blocking Queue Segfault w/ Boost

I had a need for a Blocking Queue in C++ with timeout-capable offer(). The queue is intended for multiple producers, one consumer. Back when I was implementing, I didn't find any good existing queues that fit this need, so I coded it myself. I'm…
Ben
  • 7,692
  • 15
  • 49
  • 64
2
votes
2 answers

How to call same method of a different class in multithreaded way

I have a method named process in two of my Classes, lets say CLASS-A and CLASS-B. Now in the below loop, I am calling process method of both of my classes sequentially meaning one by one and it works fine but that is the not the way I am looking…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
2
votes
1 answer

ArrayBlockingQueue - is it really Concurrent?

Not a single operation of ArrayBlockingQueue is concurrent with any of its other operations; they always take the same lock. Even for the size() method it takes a lock. public int size() { final ReentrantLock lock = this.lock; …
veritas
  • 2,444
  • 1
  • 21
  • 30
2
votes
0 answers

BlockingQueue in ServletContextAttributeListener

I'm trying to transfer data (from a thread started in a ServletContextListener which is continuously adding data to the queue) to a ServletContextAttributeListener. The data from the queue needs to be passed on to the connected clients which are…
Thomas
  • 1,678
  • 4
  • 24
  • 47
2
votes
1 answer

Java ScheduledExecutorService producer\consumer

I have the next project: Spring(3.2)-based Web application(Tomcat 7), in background I have several tasks. I have a queue with some information for processing. This queue is updating periodically(but just when it empty). Also I have several threads…
2
votes
3 answers

notify() instead of notifyAll() for blocking queue

I am trying to find out whether it is possible to have a multiple producer / multiple consumer queue where I can use notify() instead of notifyAll(). For example, in the implementation below (source: here) you cannot just simply switch the…
chrisapotek
  • 6,007
  • 14
  • 51
  • 85
2
votes
4 answers

Java peer-to-peer thread model, everyone wait for Job

This is a schoolwork. I am trying to create peer-to-peer Thread model: http://www.informit.com/articles/article.aspx?p=169479&seqNum=5 Where the delegation model has a boss thread that delegates tasks to worker threads, in the peer-to-peer model…
Jaanus
  • 16,161
  • 49
  • 147
  • 202
2
votes
3 answers

Any efficient BlockingQueue implementations that allow combining of entries?

Are there any efficient (without synchronize everything) implementations of java.util.concurrent.BlockingQueue that allow combining of entries? By combining I mean to merge incoming item with existing "equal" entry on the queue (if there is one),…
Dusan
  • 115
  • 1
  • 7
2
votes
2 answers

having issues with BlockingQueue java , implementation of Storm (Distributed computing)?

This is the code snippt of my input spout for emmiting tuple to a processing noded for stream processing over a cluster. The problem is The BlockingQueue is throwing InterruptedException . private SpoutOutputCollector collector; public…
Rohit Haritash
  • 404
  • 5
  • 20
2
votes
1 answer

Does polling block other operations in LinkedBlockingQueue?

In the pseudocode below I have a poll() function that gets called forever in the main thread. When I do this without the sleep() statement in poll(), only 2-3 items a minute get added to the queue by the other thread. Does this mean that polling…
fibera
  • 495
  • 3
  • 8
  • 15
1
vote
3 answers

BlockingQueue - Fetch only specific object.

I have the following blockingQueue; final BlockingQueue blockingQueue = new LinkedBlockingQueue(); where public class Message { private String author; private String text; ....... //setters and…
danny.lesnik
  • 18,479
  • 29
  • 135
  • 200
1
vote
1 answer

Channel for sharing data between threads

I have a requirement where I need to read text file then transform it and write it to some other file. I wish to do this in parallel fashion like one thread for read, one for transform and another for write. Now to share data between threads I need…
Premraj
  • 7,802
  • 8
  • 45
  • 66
1
vote
1 answer

Java measure utilization of threads

I have a blocking queue and workers taking from that queue and then working for around 1-10ms. I would like to figure out some relative figure of how much time the worker was active and idle in a given time frame (e.g 70% active in last…
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149