diff --git a/src/main/java/com/jthemedetecor/MacOSThemeDetector.java b/src/main/java/com/jthemedetecor/MacOSThemeDetector.java index e5b53e5..a9dc130 100644 --- a/src/main/java/com/jthemedetecor/MacOSThemeDetector.java +++ b/src/main/java/com/jthemedetecor/MacOSThemeDetector.java @@ -39,12 +39,11 @@ class MacOSThemeDetector extends OsThemeDetector { private final Set> listeners = Collections.synchronizedSet(new HashSet<>()); private final Pattern themeNamePattern = Pattern.compile(".*dark.*", Pattern.CASE_INSENSITIVE); - private final Object iterateLock = new Object(); private final Callback themeChangedCallback = new Callback() { @SuppressWarnings("unused") public void callback() { - synchronized (iterateLock) { + synchronized (listeners) { notifyListeners(isDark()); } } @@ -100,14 +99,14 @@ private boolean isDarkTheme(String themeName) { @Override public void registerListener(@NotNull Consumer darkThemeListener) { - synchronized (iterateLock) { + synchronized (listeners) { listeners.add(darkThemeListener); } } @Override public void removeListener(@Nullable Consumer darkThemeListener) { - synchronized (iterateLock) { + synchronized (listeners) { listeners.remove(darkThemeListener); } }