Skip to content

Commit

Permalink
Fix singleton to be thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Feb 25, 2024
1 parent 39103f5 commit 581b6f7
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ public boolean willGainFocus(CDockable dockable) {
FileUtil.readProperties(new File(dataFolder, "persistence.properties"), localPersistence);
}

private static class Holder {
private static final UICore INSTANCE = new UICore();
}

public static UICore getInstance() {
if (INSTANCE == null) {
INSTANCE = new UICore();
}
return INSTANCE;
return Holder.INSTANCE;
}

private void readSystemPreferences(BundleContext context) {
Expand Down

0 comments on commit 581b6f7

Please sign in to comment.