??
package com.codegym.task.task17.task1706;
/*
Synchronized president
*/
public class Solution {
public static void main(String[] args) {
OurPresident expectedPresident = OurPresident.getOurPresident();
OurPresident ourPresident = OurPresident.getOurPresident();
System.out.println(expectedPresident == ourPresident );
}
public static class OurPresident{
private static OurPresident president;
private OurPresident() {
}
public static synchronized OurPresident getOurPresident(){
return getOurPresident();
}
static {
synchronized (OurPresident.class){
president = new OurPresident();
}
}
}
}