Photo by Emile Perron on Unsplash

We’ve all struggled with understanding concurrency in Java. Even though your code looks and works fine on your system, concurrency bugs are uninvited and the code might still be broken and fail at any moment.

In this post, we will look at one of the methods to initialize a Singleton class in Java. The singleton is expected to be used by multiple threads and only one instance must be created.

Let’s first look at how it’s done when it is expected to be used by a single thread. …

Sumant Patil

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store