Skip to content

Instantly share code, notes, and snippets.

@josinSbazin
Created July 3, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josinSbazin/11d519e93a994e5708d032ee989069dc to your computer and use it in GitHub Desktop.
Save josinSbazin/11d519e93a994e5708d032ee989069dc to your computer and use it in GitHub Desktop.
level17.lesson04.task04
package com.javarush.test.level17.lesson04.task04;
/* Синхронизированный президент
И снова Singleton паттерн - синхронизация в статическом блоке
Внутри класса OurPresident в статическом блоке создайте синхронизированный блок.
Внутри синхронизированного блока инициализируйте president.
*/
public class Solution {
public static class OurPresident {
private static OurPresident president;
static {
synchronized (OurPresident.class) {
president = new OurPresident();
}
}
private OurPresident() {
}
public static OurPresident getOurPresident() {
return president;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment