Questions tagged [linkedblockingqueue]
14 questions
3
votes
1 answer
Runnable locked (park) using ExecutorService and BlockingQueue
Note: I understand the rules site, but I can't to put all code (complex/large code).
I put a DIFFERENT (all the real code is too much and you don't need here) code in Github but reproduces the Problem (the main class is…

joseluisbz
- 1,491
- 1
- 36
- 58
2
votes
1 answer
Java - BlockingQueue freezes multithread application
I'm making an application that contains of two threads: one of them writes a value to LinkedBlockingQueue, another is reading. I'm using ScheduledExecutorService for running this operations in some period in seconds.
The problem is that my…

Alexander Tukanov
- 503
- 6
- 20
1
vote
0 answers
Is stream().takeWhile thread safe on LinkedBlockingQueue
can anyone explain me if in java
//Thread 1
BlockingQueue queue = new LinkedBlockingQueue<>();
queue.put("232323232");
.....
//Thread 2
Stream result = queue.stream().takeWhile(predicate);
is thread safe? ... if one thread is puts…

simonC
- 4,101
- 10
- 50
- 78
1
vote
1 answer
Java take() Method of LinkedBlockingQueue is stuck, even if the Queue should not be empty
I'm writing Code for a Network Application. Therefor I'm using a LinkedBlockingQueue to store incoming messaged until they are consumed. The following code runs in it's own Thread and fills up the Queue:
while(true) {
String msg =…
user11318028
1
vote
1 answer
Java BlockingQueue with multiple consumer threads unfair
I'm creating a resource pool using a (java) LinkedBlockingQueue, where
the resource elements are equivalent, belong to a pool where their ordering is indifferent.
the consumers are competing threads grabbing one resource at a time, with a "pull"…

artejera
- 1,346
- 1
- 11
- 19
0
votes
0 answers
Issue with LinkedBlockingQueue in java application
I am using LinkedBlockingQueue in my application. When the application is running the program waits at blockingqueue.take() statement. Even though after adding some objects into the queue, it is not progressing further.
The sample…
0
votes
0 answers
Take two items from BlockingQueue with latch countDown
Hi I have multithread environment.
Its like a producer and subscriber problem.
but the challenge is i will have multiple producers and consumers also in multi number.
I tried two approaches. Approach1 with BlockingQueue and approach2 with…

user2555212
- 165
- 1
- 14
0
votes
1 answer
How efficient are BlockingQueues / what's their effect on CPU time?
I am making an online game in Java and I ran into one particular issue where I was trying to find the most efficient way to send clients spawn entity NPC packets. I of course understand how to send them but I wanted to do it off of the main game…
0
votes
1 answer
Do while loop behaving unexpectedly, for some inexplicable reason
I've been all over the internet and the Java docs regarding this one; I can't seem to figure out what it is about do while loops I'm not understanding. Here's the background: I have some message handler code that takes some JSON formatted data from…
0
votes
1 answer
Does a ChronicleQueue block on reads after a tailer has retrieved the most recently written excerpt?
I too am beginning to look at ChronicleQueue.
From the documentation:
Reading the queue follows the same pattern as writing, except there is a possibility there is not a message when you attempt to read it
I am trying to understand what happens…

Jack Copper
- 33
- 1
- 9
0
votes
1 answer
LinkedBlockingQueue fullyLock() throw exception, fullyUnlock() won't execute
fullyLock() contains 2 locks:putLock and takeLock, they are all ReentrantLock and NonfairSync
void fullyLock() {
putLock.lock();
takeLock.lock();
}
Will there be such a situation :
In remove() method, putLock.lock() success,…

jianjian
- 1
0
votes
1 answer
Why does "LinkedBlockingQueue#put" need "notFull.signal()"
The source code of put method of LinkedBlockingQueue in JDK 1.8:
public void put(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
// Note: convention in all put/take/etc is to preset local var
//…

xingbin
- 27,410
- 9
- 53
- 103
0
votes
0 answers
Ensure capacity in BlockedQueue
I am using a bounded LinkedBlockingQueue in a multi threaded environment.
I have a single threaded consumer which performs the following using a ScheduledExecutorService every N seconds:
try {
current =…

Emil Gelman
- 125
- 1
- 10
-2
votes
3 answers
Using ` LinkedBlockingQueue` may cause null pointer exception
I am learning java concurrent programming recently. I know that the final keyword can guarantee a safe publication. However, when I read the LinkedBlockingQueue source code, I found that the head and last field did not use the final keyword. I…

caihuadaye
- 1
- 2