Findbug refers to a potential thread issue. In a multi-threaded environment, it is likely that your singleton will be created multiple times with your current code.
It reads a lot here, but it helps to explain.
The race status here is on if check . At the first call, the thread will fall into the if check and create an instance and assign it to the "instance". But there is the potential for another thread to become active between if check and instance creation / assignment. This thread can also pass if check , because the assignment has not yet been completed. This way, two (or more if more threads) are created, and your threads will refer to different objects.
nicholas.hauschild Jul 21 2018-11-21T00: 00Z
source share