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

Server socket read file: Unable to process records from BlockingQueue

I am trying to send a text file from a client to Socket Server. The text file is read using a single thread in sequential operation. I am using BlockingQueue to place the records from read operation and trying to process the records using…
rslack
  • 61
  • 1
  • 5
0
votes
1 answer

ExecutorService doens't work

I have problem using Executorservice I implemented Consumer-Producer Pattern Main import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import…
minji
  • 512
  • 4
  • 16
0
votes
0 answers

PriorityBlockingQueue not correctly working

I have a java app using Spring framework. My application consists on multiple producers and once consumer. I declare a shared queue between producers and consumers like this:
Willy
  • 9,848
  • 22
  • 141
  • 284
0
votes
2 answers

Blocking Queue usage scenario

I am working on a design where I am processing all the exceptions caught in catch blocks to send to a server via webservice call. The idea is not to block the main app at all while doing this job. I felt blocking queue pattern is appropriate for…
Vik
  • 8,721
  • 27
  • 83
  • 168
0
votes
1 answer

Can I implement blocking queue with two objects serving as locks in Java?

I am trying to understand Java's synchronized keyword, wait(), and notify() by implementing a blocking queue class. One of the blocking queue implementation is described by this article. However I wonder if it is possible to use two objects serving…
Jack Chen
  • 79
  • 1
  • 7
0
votes
0 answers

How to block a thread until a task is finished

i am working on a board project where i need to display drawing points on the other side. I have 2 thread running parallel where one adds into blocking received from socket like this public class ClientThread implements Runnable { …
Prakash
  • 357
  • 2
  • 14
0
votes
1 answer

Detect position of queued tasks in thread pool

I have a ThreadPoolExecutor with a fixed core pool size and a LinkedBlockingQueue for thread pool tasks that have to wait if the entire core is busy. Assuming that all core threads are currently busy and there are further tasks enqueued into the…
PAX
  • 1,056
  • 15
  • 33
0
votes
1 answer

how to tell if every Thread of a ThreadPool is waiting

i have a ThreadPool with a lot of threads. the task is finished if every thread of this threadpool is waiting on a BlockingQueue. how can i figure out if every Thread is waiting so i can shutdown the threadpool?
Exagon
  • 4,798
  • 6
  • 25
  • 53
0
votes
1 answer

BlockingQueue's put() and high concurrency

I'm using the Fork/Join Framework to do a lot of calculations in parallel. I've implemented the Producer-Consumer Pattern with a simple logger to create console outputs while the programm is calculating. The producer and consumer share a…
cmtjk
  • 359
  • 2
  • 12
0
votes
1 answer

Strange behaviour arrayBlockingQueue with array elements

I am having some strange behavior with the use of an ArrayBlockingQueue which I use in order to communicate between certain treads in a java application. I am using 1 static ArrayBlockingQueue as initialised like this: protected static…
Ylva
  • 33
  • 5
0
votes
2 answers

How to provide capacity for a LinkedTransferQueue?

Currently I'm reading Collections in java. As I read, LinkedTransferQueue is superset of LinkedBlockingQueue whose put(E e) method inserts and object and returns void and if need, will block until space in the queue becomes available. But I don't…
Deepankar Singh
  • 662
  • 1
  • 9
  • 20
0
votes
0 answers

Best solution to cut total execution time to minimum (program manipulates input and output data)

I have program that uses 4 input .txt files. When program is started, certain data manipulation is done, data is grabbed from those 4 files, and program creates 2 output .txt files at the end. Program execution time at that time is about 18 seconds.…
DarioBB
  • 663
  • 2
  • 8
  • 29
0
votes
0 answers

Java BlockingQueue take() vs poll(time, unit)

I think mistakenly guys compared take() vs poll(), but I found that it is reasonable to compare take() vs poll(time, unit) as both provided by BlockingQueue and both are blocking tell queue not Empty "and in case or poll or time-out", OK lets start…
Bassem Reda Zohdy
  • 12,662
  • 3
  • 33
  • 39
0
votes
0 answers

Custom event listener using Java

I have created an application that listens to incomming messages from an AS400 DataQueue. The application is running in a Java application server (Glassfish). I am using the jt400 library to connect and read from the Dataqueue. Reading from a…
0
votes
1 answer

How to implementing BlockingQueue with Custom Comparator with ThreadExecutor?

I am trying to run task based on length of string in ascending order. However its not working as expected. Here is code I have tried till now: import java.util.Comparator; import java.util.concurrent.BlockingQueue; import…
virendrao
  • 1,763
  • 2
  • 22
  • 42