456 questions
0 votes
1 answer
53 views
Implementing Custom Kafka Consumer based on LinkedBlockingQueue can not return size
Found that KafkaConsumer is quite inconvenient for testing, tried to implement it myself based on LinkedBlockingQueue. Using Spring Boot, Java 21, Guava and Kafka Testcontainers 7.8.2. Here is what it ...
1 vote
1 answer
222 views
Java PriorityBlockingQueue blocking behavior
From the docs I see, that the take() method blocks until an element becomes available. Is there any other scenario when it could block? What I mean is, is there a possible scenario, when the queue is ...
0 votes
0 answers
46 views
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 ...
0 votes
0 answers
56 views
Is there a way to co-ordinate coroutines using on Dispatchers with wait statements across codeblocks
I have a situation with a lot of callbacks, specifically onCompleteListeners from Firebase Auth. First I am getting a Firebase Auth object using an SDK. However there is no other option but to use ...
0 votes
1 answer
169 views
Websocket with BlockingQueue subscription
I want to build a GraphQl-like subscription where a client via websocket can ask the Akka Http server to subscribe to updated results from a database and push them back via websocket to the client. My ...
0 votes
1 answer
583 views
How to poll() and remove item from ArrayBlockingQueue without memory allocation
I am trying to poll an ArrayBlockingQueue to get the item: public void run() { while (true) { if (Thread.currentThread().isInterrupted()){ closeAppender(); ...
0 votes
0 answers
344 views
Java data structure where elements automatically removed after specified delay for every element
Does anybody know if there is existing Java data structure where elements are automatically removed from it based on the delay for each element? In other words, each element has its own ttl. For ...
0 votes
0 answers
80 views
Does using removeIf() on an ArrayBlockingQueue trigger a put() call from another thread?
I'm trying to remove elements manually from ArrayBlockingQueue by using the removeIf() method, using threads. And then have another thread trying to put an element into the ArrayBlockingQueue. It ...
0 votes
1 answer
98 views
Obtaining a Synchronized List of BlockingQueues in Java [duplicate]
I'd like to work with the following data structure: List<BlockingQueue<AtomicInteger>> listOfQueues = Collections.synchronizedList( new ArrayList<ArrayBlockingQueue<...
1 vote
2 answers
87 views
java concurrency: BlockingQueue based producer/consumer does not seem to work well with compound actions that needs synchronized code block?
It comes to a surprise to me when I am trying to implement some compound actions with a BlockingQueue based producer/consumer pattern, which makes me think I most likely have missed something obvious. ...
0 votes
1 answer
242 views
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 ...
0 votes
1 answer
388 views
Problem combining Delay Queue and Executor Service
I'm trying to create an Executor Service using a DelayQueue for the blocking queue with Java 8. I created a class that implements Runnable and Delayed, and implemented the required methods: public ...
0 votes
1 answer
306 views
Implementing BlockingQueue using Semaphores only
I'm having a trouble with my code design and can't find a solution. I am implementing a BlockingQueue using Semaphores (TaggedSemaphores, to be precise) without loops, condvars, mutexes, and if-else ...
0 votes
0 answers
35 views
ThreadPoolExecutor really only executing amount if tasks given?
In my Main Class I'm calling the Runnable Class Browser multiple times with an URL using blockingQueue.offer(..), which is linked to my ThreadPoolExecutor pool = new ThreadPoolExecutor(...
0 votes
1 answer
73 views
How to show JList from a blockingQueue?
I'm using multi threading with Java, I have a thread that will post a message into a queue, a blockingQueue which is thread safe, and I have another thread, implementing a GUI with swing. Everytime I'...