All Questions
Tagged with java multithreading
39,521
questions
0
votes
0
answers
21
views
Using Circuit Breaker within Virtual Threads
Our application is based on Spring Boot 3.2 and runs on JDK 21. We've gone all-in on virtual threads, and can't sing their praises enough. Tomcat handles all requests with a virtual thread pool, our ...
-2
votes
0
answers
25
views
If thread invalidates its cache after acquiring lock and flush its cache before release lock why is it necessary to make variable volatile in singleto [closed]
If thread invalidates its cache after acquiring lock and flush its cache before release lock why is it necessary to make variable volatile in singleton pattern, since thread which aquires the lock ...
1
vote
0
answers
50
views
Spring Boot application gets stuck when virtual threads are used on Java 21
I've ran into an issue related to performance of Spring Boot 3 application with virtual threads enabled.
TLDR reproduction steps:
Checkout https://github.com/stsypanov/concurrency-demo
Run ...
-1
votes
0
answers
16
views
Cache with multiple request [closed]
I have situation where I am maintaining a counter in cache , getting multiple requests from different servers of app trying to update that counter. How to keep the counter consistent
I want a starter ...
1
vote
1
answer
32
views
All thread blocked in a pool while handling multiple tasklist
I have some problems while using ThreadPoolExecutor and I cannot figure it out.
I try to use two List<CompletableFuture<Void>> taskList lists to store tasks and then submit to a threadpool ...
1
vote
1
answer
92
views
Java concurrency problem by multi-thread not occured and automatically synchronized
I’m trying to test a multi-threaded concurrency problem.
What I expected is that the result should be less than 0 (not always but sometimes), because it is not synchronized.
Notice the pair of println ...
0
votes
1
answer
71
views
How to instantiate Singleton objects for other classes in a different class in Java?
public class Singleton {
private volatile static A AInstance = null;
private volatile static B BInstance = null;
private Singleton() {
}
public static synchronized A ...
0
votes
1
answer
54
views
What problems can I have with spawning a set of new threads from Servlet and what alternatives exist?
For simplicity, I will omit some details and try to highlight the main point:
I have a servlet that consumes users' requests, when a user sends a request I need to gather data from many endpoints. One ...
0
votes
1
answer
67
views
Robot class in Javafxml
I am a beginner, and I have a question regarding Robot class in JavaFX. I have the following code.
Basically, when I manually click on AnchorPane, method click gets activated, and when the mouse ...
-1
votes
1
answer
50
views
Using AtomicInteger as counter for List [closed]
I am learning multi threading. I have below code which implements round robin algorithm over an CopyOnWriteArrayList. List will always have a fixed number of elements let's suppose 10.
...
1
vote
1
answer
42
views
Java CopyOnWriteArrayList add element if not exists already
I have an CopyOnWriteArrayList as my code should be thread safe.
List friuts = new CopyOnWriteArrayList<>();
I don't want to have duplicate friuts in list I cannot use Set as I want to have ...
1
vote
1
answer
64
views
Can time slicing and context switches cause high CPU utilization in a Java based application?
I have a Play framework application with about 400 threads. 200 are part of the default dispatcher.
Now I have 2 db sources with 9 connections each and thread pool with a min size of 20 and max of 200....
1
vote
1
answer
73
views
Multithreaded program not running as expected
I was trying to learn about semaphores, reading The Little Book of Semaphores by Allen B. Downey.
In that there is a puzzle:
Generalize the rendezvous solution. Every thread should run the
following ...
2
votes
1
answer
60
views
Difference of behaviors between Virtual Threads & Classical Threads regarding 'synchronized'?
A lot of open-source projects are trying to get away from using syncrhonized due to its behavior with Virtual Thread.
Regarding Virtual Threads, I understand that within a synchronized block, in ...
0
votes
0
answers
41
views
Concurrency and Multi-threading
How can one implement a custom ReadWriteLock in Java that allows a thread to upgrade a read lock to a write lock without risking deadlock?