Всем привет) Уперлась в потолок, не понимаю, что нужно сделать) Посоветуйте, пожалуйста, что еще почитать по синхронизации и, возможно, по многопоточности в целом, кроме JR, чтобы спокойно с синхронизацией работать.
package com.javarush.task.task17.task1706;
/*
Синхронизированный президент
*/
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;
static {
synchronized (new OurPresident()) {
president = null;
}
}
private OurPresident() {
}
public static OurPresident getOurPresident() {
if (president == null)
president = new OurPresident();
return president;
}
}
}