]> granicus.if.org Git - icu/commitdiff
ICU-12723 Remove double-checked locking in ICUNotifier.
authorAndy Heninger <andy.heninger@gmail.com>
Thu, 10 Nov 2016 22:32:56 +0000 (22:32 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Thu, 10 Nov 2016 22:32:56 +0000 (22:32 +0000)
X-SVN-Rev: 39503

icu4j/main/classes/core/src/com/ibm/icu/impl/ICUNotifier.java

index 9e833723462612036f2a8508a1e04448548372d6..59fe345dadfb3aaed96f9a41b0a017593a1931f2 100644 (file)
@@ -68,7 +68,7 @@ public abstract class ICUNotifier {
 
     /**
      * Stop notifying this listener.  The listener must
-     * not be null.  Attemps to remove a listener that is
+     * not be null.  Attempts to remove a listener that is
      * not registered will be silently ignored.
      */
     public void removeListener(EventListener l) {
@@ -98,16 +98,14 @@ public abstract class ICUNotifier {
      * is called on each listener from the notification thread.
      */
     public void notifyChanged() {
-        if (listeners != null) {
-            synchronized (notifyLock) {
-                if (listeners != null) {
-                    if (notifyThread == null) {
-                        notifyThread = new NotifyThread(this);
-                        notifyThread.setDaemon(true);
-                        notifyThread.start();
-                    }
-                    notifyThread.queue(listeners.toArray(new EventListener[listeners.size()]));
+        synchronized (notifyLock) {
+            if (listeners != null) {
+                if (notifyThread == null) {
+                    notifyThread = new NotifyThread(this);
+                    notifyThread.setDaemon(true);
+                    notifyThread.start();
                 }
+                notifyThread.queue(listeners.toArray(new EventListener[listeners.size()]));
             }
         }
     }