I have this static block of code which is following Singleton design pattern.
class Employee{
private static Employee emp;
static {
if (emp==null){
emp=new Employee();
}
}
public static Employee getEmployee(){
return emp;
}
}
My doubt is if this code can be accessed by Mutiple threads concurrently and break the singleton logic.
Is it posible initially that when multiple threads try to load the employee object run the static code concurrenctly? and then break the singleton mechanism in the code?