Top "Java.util.concurrent" questions

Java package which contains utility classes commonly useful in concurrent programming.

Java Remove Specific Item From ConcurrentHashMap

Is using the remove() method okay? I've read an article that synchronization hasn't been added to the remove method. How …

java thread-safety java.util.concurrent concurrenthashmap
ExecutorService awaitTermination gets stuck

I made a fixed size thread pool with Executors.newFixedThreadPool(2), and I executed 10 Runnable objects. I set breakpoints and traced …

java multithreading executorservice java.util.concurrent
ThreadPoolExecutor and the queue

I thought that using ThreadPoolExecutor we can submit Runnables to be executed either in the BlockingQueue passed in the constructor …

java multithreading concurrency java.util.concurrent threadpoolexecutor
CompletableFuture from Callable?

Today I experimented with the "new" CompletableFuture from Java 8 and found myself confused when I didn't find a runAsync(Callable) …

java concurrency java-8 java.util.concurrent
ExecutorService.invokeAll does NOT support collection of runnable task

Wanted to run collection of Runnable task through invokeAll(..) method of ExecutorService. But that's not supported as of now (supports …

java executorservice java.util.concurrent
Concurrent Map with fixed size

I need a map with the following requirements : It should be highly concurrent. The put(), get() and remove() methods may …

java multithreading concurrency java.util.concurrent concurrenthashmap
How to do a lazy create and set with AtomicReference in a safe and efficient manner?

I'm looking to lazily create something and cache the results as an optimization. Is the code below safe and efficient, …

java concurrency java.util.concurrent
Reinitialize fix delay in ScheduledExecutorService

As per my requirement, I have to execute some particular code after certain period of time. To do the same …

java java.util.concurrent
Do we need to make ConcurrentHashMap volatile?

We have a shared ConcurrentHashMap which is read and written by 2 threads. class Test { private ConcurrentHashMap<Object, Object> …

java concurrency java.util.concurrent
Are there any drawbacks with ConcurrentHashMap?

I need a HashMap that is accessible from multiple threads. There are two simple options, using a normal HashMap and …

java multithreading hashmap concurrenthashmap java.util.concurrent