Thread-Safety and Sets in Java

1. Overview Java provides various Set implementations tailored for different use cases. In this tutorial, we're going to examine these Set implemen...

Continue Reading

Start Tasks Simultaneously using Java Synchronizers

1. Introduction When we execute a task using a thread pool or a dedicated thread, it runs without being aware of other threads. However, there are ...

Continue Reading

Guide to JVM Shutdown

1. Overview In this tutorial, we're going to investigate the details of the JVM shutdown. Firstly we'll see in which conditions the JVM shuts down....

Continue Reading

Handling Exceptions from ExecutorService Tasks

1. Overview ExecutorService is the central mechanism to execute tasks in Java. When we run our tasks in a thread pool backed by an ExecutorService,...

Continue Reading

Guide to Thread Interruption in Java

1. Overview Thread interruption is a mechanism to signal a thread that it must stop its execution at a convenient point. However, it is up to the r...

Continue Reading

Task Cancellation in Java

1. Overview In Java, there is no safe way to preemptively stop a task running on a Thread in that the task must cooperate and be responsive to the ...

Continue Reading

Submit Tasks in Batch using ExecutorService

1. Overview In this tutorial, we're going to look at how we can submit tasks in batch using the ExecutorService implementations. 2. Sample Applicat...

Continue Reading

Shut Down Thread Pool using Java ExecutorService

1. Overview In this tutorial, we'll look at how we can shut down a thread pool using Java ExecutorService. We'll evaluate two different approaches:...

Continue Reading

Create Thread Pool using Java ExecutorService

1. Overview In this tutorial, we're going to examine how we can create a thread pool using ExecutorService. We'll start with the Executors class si...

Continue Reading

CyclicBarrier in Java

1. Introduction In this tutorial, we're going to look at how we can use CyclicBarrier in Java. Primarily, a CyclicBarrier allows threads to wait fo...

Continue Reading