Given a Java ConcurrentMap, I would like to atomically:Check if an entry is contained in the mapIf it is present, run an action (I'm thinkng of a BiConsumer taking the key and its value)Otherwise, ...
In Java, when using scheduleAtFixedRate, is it possible for a task to execute before the ScheduledFuture returned by scheduleAtFixedRate has been assigned?For example, could the following code throw ...
When working with JNI, can the native side obtain an _Atomic int32_t* given a Java AtomicInteger reference, and run C atomic functions on it (e.g. atomic_fetch_add)?We could call Java's methods (e.g. ...
For a parallel Stream, the collect method has a 3-arg variant: (source: oracle documentation )/**Parameters:supplier - a function that creates a new result container. For a parallel execution, this ...
I'm using java.util.concurrent.ScheduledExcecutorService.scheduleAtFixedRate to execute a task periodically. I run it once every minute and it usually completes after 5 seconds, but occasionally runs ...
I have a multithreaded program that both produces output via a timer and receives user input. It behaves badly when I want to type in a command such as "pause" or "stop": anything ...
I attempted to replicate the experiment about "Release/acquire" from Doug Lea‘s blog on j9mm (https://gee.cs.oswego.edu/dl/html/j9mm.html#summarysec) :volatile int ready; // Initially 0, ...
I have generated java protobuf class. This class has protobuf extensions also. Is it safe to modify different unrelated fields and extensions of the same protobuf builder in parallel?message ...
Im trying to create a Java App using SpringBoot 3 framework and GraphQL. I'm trying to resolve a field which depends on several dataLoaders within my App however, I seem to be running into an issue ...
I'm currently working on a concurrent implementation of multiplayer Tetris in JavaFX where each game is run on a separate Stage. Each game has its own set of inputs so you can play simultaneously as ...
Edit: I've cut down Mainboard to just the relevant function to make code shorter to read. If any additional code needs to be read to help understanding, please sayI'm currently making a multiplayer ...
I need to asynchronously consume future value and then run logic X. In case of any exceptions, I also want to execute logic X. In a way, it is semantically akin to the finally block.I do not have a ...
The class implementation below wraps two AtomicInteger fields. After the max=9999 value is reached, the main sequence number is expected to reset to zero. When the sequence number resets, the ...
I have not used Java in a million years and trying to figure out how to differentiate between different types of Exception in CompleteableStage.Currently, I have something like below but it does not ...
I have a problem regarding spring DefaultManagedTaskExecutor. We are deploying our SpringBoot 3.2.5 application to websphere Liberty and we are using Liberty ManagedExecutorService as external ...