Improving performance: non-blocking processing of streams

1 Introduction Imagine we have an application that needs to access an external web service in order to gather information about clients and then process it. More specifically, we can’t get all this information in a single invocation. If we want to look up different…

Java Concurrency Tutorial – Locking: Explicit locks

1 Introduction In many cases, using implicit locking is enough. Other times, we will need more complex functionalities. In such cases, java.util.concurrent.locks package provides us with lock objects. When it comes to memory synchronization, the internal mechanism of these locks is the same as with…

Java Concurrency Tutorial – Locking: Intrinsic locks

1 Introduction In previous posts we reviewed some of the main risks of sharing data between different threads (like atomicity and visibility). Additionally, we learnt how to design classes in order to be shared safely (thread safe designs). In many situations though, we will need…

Java Concurrency Tutorial

This Java concurrency tutorial consists of several posts that explain the main concepts of concurrency in Java. It starts with the basics with posts about the main concerns or risks of using non synchronised programs. This tutorial consists on two main areas: Basic concepts about…

Java Concurrency Tutorial – Thread-safe designs

1 Introduction After reviewing what the main risks are when dealing with concurrent programs (like atomicity or visibility), we will go through some class designs that will help us prevent the aforementioned bugs. Some of these designs result in the construction of thread-safe concurrency solutions….

Java Concurrency Tutorial – Visibility between threads

1 Introduction When sharing an object’s state between different threads, other issues besides atomicity come into play. One of them is visibility between threads. The key fact is that without synchronization, instructions are not guaranteed to be executed in the order in which they appear…