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
0
votes
2 answers

ArrayBlockingQueue: concurrent put and take

Why ABQ has not been implemented using the way LinkedBlockingQueue. We can use AtomicInteger to keep Track count in ABQ also the same way LBQ does. We can use the Two Locks for ABQ too. I stumble upon the similar question on SO. ArrayBlockingQueue…
0
votes
2 answers

LinkedBlockingQueue program does not terminate

If I run the following program, the JVM will not terminate after execution. However, if I uncomment the line (// newFixedThreadPool.execute(new Producer3());) from the code, the program terminates after execution. I am aware because of the blocking…
TheMonkWhoSoldHisCode
  • 2,182
  • 3
  • 26
  • 40
0
votes
1 answer

Java BlockingQueue Messages Lagging issue between threads

I have implemented a two player game with thread pool of sockets. each player connects to their own thread. I added a message Queue system according to this article. Problem is the messages are lagging. the first respond from the first player is…
Dan Jay
  • 874
  • 10
  • 27
0
votes
1 answer

Data structure for buffering encoded audio in android

I have TCP client which received audio (encoded) data through socket. I have to keep received data in some buffer and provide to decoder when requested by decoder chunk by chunk. Data is in byte[] and array size can vary. What should I use as buffer…
SohailAziz
  • 8,034
  • 6
  • 41
  • 43
0
votes
2 answers

for each in blocking collection

Suppose I have an instance of LinkedBlockingQueue queue; and want to use for each with this queue: for(Object obj : queue) { //do smth } How will this code behave in case if queue is empty at the moment? Will it block the running until queue…
0
votes
1 answer

is there a blocking queue in Java that only allows peek?

I need a blocking queue that has a size of 1, and every time put is applied it removes the last value and adds the next one. The consumers would be a thread pool in which each thread needs to read the message as it gets put on the queue and decide…
adnan_252
  • 411
  • 2
  • 4
  • 10
0
votes
2 answers

how can initialize size of blocking queue with ArrayBlockingQueue() to show get msg in another thread

BlockingQueue queue = new ArrayBlockingQueue(10); for(int i=0; i(); } System.out.println("queue size in main "+queue.size()); ***// queue.size() returning 0…
GeekAbhiGeek
  • 11
  • 1
  • 7
0
votes
2 answers

Elegant/efficient way reading millions of records in MySQL Database, Java

I have a MySQL database with ~8.000.000 records. Since I need to process them all I use a BlockingQueue which as Producer reads from the database and puts 1000 records in a queue. The Consumer is the processor that takes records from the queue. I am…
RazorAlliance192
  • 722
  • 9
  • 23
0
votes
2 answers

Text is not getting printed once the Threads are done

Please have a look at the following code. public class BigFileWholeProcessor { private static final int NUMBER_OF_THREADS = 2; public void processFile(String fileName) { BlockingQueue fileContent = new…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
2 answers

Thread that never ends

Here is my code: public class BigFileReader implements Runnable { private final String fileName; int a = 0; private final BlockingQueue linesRead; public BigFileReader(String fileName, BlockingQueue linesRead) { …
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
1 answer

BlockingQueue inside Transaction java

I am in process of building a system which has a basic Produce Consumer paradigm flavor to it, but the Producer part needs to be a in a Transaction mode. Here is my exact scenario : Poller Thread - [Transaction START] Polls the DB for say 10…
duskandawn
  • 646
  • 1
  • 10
  • 19
0
votes
1 answer

software design for multiple producer single consumer in Java

I have multiple producers, each pushing data into there own Blocking queues. The data from each producer is processed independently, (hence the separate queues). My single consumer currently polls each of those queues, with a timeout on each. …
user3312154
  • 235
  • 3
  • 14
0
votes
2 answers

blocking call on two Queues?

I have an algorithm (task in VxWorks) that is reading data from multiple queues to be able to manage priorities accordingly. Now , the msgQReceive( ) function, can be set to WAIT_FOREVER which would make it a blocking call until something is…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
0
votes
2 answers

Need a simple answer about Queues in Java

I'm trying to use an ArrayBlockingQueue but I cant seem to get the syntax right and I dont know what exactly I'm supposed to import to use it. I tried this: BlockingQueue Queue = new ArrayBlockingQueue(100); for the declaration but it…
seanscal
  • 568
  • 2
  • 9
  • 33
0
votes
0 answers

java - blockingQueue with condition Issue

I've two threads the first one execute some tasks (called TaskManager) and the second listen to events and store them in a queue (called EventManager). EventManager should be woken up and start running only if the queue is not empty and some…
IgalS
  • 31
  • 3