Home » Java Concurrency

Tag Archives: Java Concurrency

java.util.concurrent.ConcurrentNavigableMap Example

In this example we shall show you how to make use ConcurrentNavigableMap Interface, ConcurrentNavigableMap is a NavigableMap which provides navigation methods that returns the closest match for given search targets with a concurrent access support for its submaps. The submaps are the maps returned by various methods like headMap(K toKey), tailMap(K fromKey) and subMap(K fromKey, K toKey).       ConcurrentNavigableMap ...

Read More »

java.util.concurrent.atomic.AtomicLongArray Example

In this example we shall show you how to make use of AtomicLongArray class,  AtomicLongArray is a long array in which elements may be updated atomically. In a multithreading concurrent application architecture, we have a few tasks which are parallelized in such a way as to require no coordination between threads. The true problem comes when we need a coordination between ...

Read More »

java.util.concurrent.ThreadLocalRandom Example

In this example we shall show you how to make use of ThreadLocalRandom class, ThreadLocalRandom is a random number generator like its parent Random class. Like the global Random generator class, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise be modified.         1. ThreadLocalRandom Advantages ThreadLocalRandom provide more good performance and less overhead in ...

Read More »

java.util.concurrent.FutureTask Example

In this example we shall show you how to make FutureTask, FutureTask is an implementation of Future which offers a very elegant way to implement parallel execution of tasks in Java where a big task can be split into small chunks and if each of those chunks can be executed in parallel, it can result in better response times and throughput. We can ...

Read More »

Java Synchronized Keyword Example

In this example, we shall show you how to use the Java synchronized keyword and achieve synchronization in java. 1. What is Synchronized Keyword in Java? Java allows us to use concurrency and multithreading pretty easily. Some of the most common use cases are those in which we have an object and many threads interacting with it. This can create ...

Read More »

java.util.concurrent.DelayQueue Example

In this example we shall show you how to make use of DelayQueue class. DelayQueue is an unbounded time-based scheduling BlockingQueue of Delayed elements backed by a heap where an element can only be taken when its delay has expired. If multiple elements have expired delays, the element with the longest delay expiration will be taken first.       DelayQueue characteristics: DelayQueue is ...

Read More »