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
1
vote
1 answer

Read messages which are 10 minutes old in java

There is a producer and consumer I am trying to implement. Where producer will keep pushing messages into queue. But while consumer has to read those messages only after 30 minutes from the time it reached the queue. Suppose m1 reaches at 10am m2…
786543214
  • 855
  • 4
  • 14
  • 29
1
vote
1 answer

Spring boot thread pool executor rest template behavior in case queueCapacity is 0 is decreasing performance for a rest apis application

I am stuck with a strange problem and not able to find out its root cause. This is my rest template thread pool executor : connectionRequestTimeout: 60000 connectTimeout: 60000 socketTimeout: 60000 responseTimeout: 60000 connectionpoolmax:…
1
vote
0 answers

Want to keep code from executing until user presses button (JavaFx Button)

I have a pretty simple game that I'm making (with a pretty basic gui) and it uses JavaFx buttons to choose what will happen. Each button has a message and an ActionEvent tied to it. When I run the method though the program doesn't stop to wait for…
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
1
vote
1 answer

BlockingQueue - one producer multiple consumers

I have three threads. Thread 1 (T1) is the producer, which generates data. Threads 2 an 3 (T2, T3 respectively) each wait on T1's data to process in separate loops. I'm thinking of sharing a BlockingQueue between the threads and having T2 and T3…
1
vote
1 answer

How to stop/destroy a thread with a blocking call gracefully upon call of C++ destructor?

In the following class a worker thread is started within constructor. The worker has a blocking call to a queue. It works as expected, but when the AsyncQueue object gets out of scope (for whatever reason), its destructor is called. Also, the…
MichaelW
  • 1,328
  • 1
  • 15
  • 32
1
vote
1 answer

Inserting 10 MILLION RECORDS INTO DB using task executor in java

My requirement is to encrypt personal identification columns of table. For which I have written a small code which selects the data in batches and insert into new table with few extra columns. Problem is when i run my code , it works good in…
Muddassir Rahman
  • 976
  • 1
  • 9
  • 20
1
vote
0 answers

Single producer - multiple different consumers

I'm doing an uni project about a computer system intended to be used in an hospital. I have a TreeSet of Patient, where all the patients recovered in the hospital are stored. The class Patient has among other data some vital parameters associated to…
1
vote
0 answers

Can my consumer become producer (apparently) for few cases

I am solving transaction polling case using producer-consumer problem using ExecutorService and BlockingQueue. I have a list of transactions, which I want to verify and take action. I am getting a new transaction to verify continuously. Considering…
impossible
  • 2,380
  • 8
  • 36
  • 60
1
vote
0 answers

How to block the provider util the blocking queue becomes empty?

In general, I want to block the provider of a blocking queue until the queue becomes empty, and then put a batch of elements into the queue. I find a relative question here: How to block until a BlockingQueue is empty? However I'm still…
liubenxi
  • 91
  • 9
1
vote
1 answer

Why in Java BlockingQueue doesn't have if clause on notify?

I implemented my custom BlockingQueue and compared it with java.util.concurrent ArrayBlockingQueue. Here is my implementation: public class CustomBlockingQueue implements BlockingQueue { private final T[] table; private final int…
Pasha
  • 1,768
  • 6
  • 22
  • 43
1
vote
1 answer

Should blocking queue be defined in Producer Class or Consumer class?

I have made 2 classes of Producer and Consumer. Producer class creates threads and pushes the items to the blocking queue and consumer class also creates threads which takses the items from the blocking queue. Now, I was wondering one thing here.…
hatellla
  • 4,796
  • 8
  • 49
  • 101
1
vote
0 answers

LinkedBlockingQueue with one element - Reader/Writer Race Condition

LinkedBlockingQueue uses two separate ReentrantLocks, putLock and takeLock. This enables one reader and one writer to access the queue at the same time using the following methods: 1) poll() 2) take() 3) put() 4) offer() Lets say a…
Kans
  • 382
  • 3
  • 17
1
vote
1 answer

Blocking Queue Take out of Order

I have a simple blocking queue containing Integers. In a multi thread environment I am taking and adding elements to the the back of the queue. BlockingQueue test = new LinkedBlockingQueue(); The goal is to have adding in order..…
1
vote
1 answer

RejectedExecutionException occurs while using LinkedBlockingQueue(Integer.MAX_VALUE) in ThreadPoolExecutor

I'm using ThreadPoolExecutor with LinkedBlockingQueue(Integer.MAX_VALUE) for multiple tasks, but why it throws RejectedExecutionException when submit(Callable task) within 2000 tasks in websphere? Shouldn't the queue be able to contain 2.1 billion…
Joey
  • 11
  • 3