src/jdk/nashorn/internal/runtime/PropertyListenerManager.java

Print this page

        

@@ -59,11 +59,11 @@
     /**
      * Add a property listener to this object.
      *
      * @param listener The property listener that is added.
      */
-    public final void addPropertyListener(final PropertyListener listener) {
+    public synchronized final void addPropertyListener(final PropertyListener listener) {
         if (listeners == null) {
             listeners = new WeakHashMap<>();
         }
 
         if (Context.DEBUG) {

@@ -75,11 +75,11 @@
     /**
      * Remove a property listener from this object.
      *
      * @param listener The property listener that is removed.
      */
-    public final void removePropertyListener(final PropertyListener listener) {
+    public synchronized final void removePropertyListener(final PropertyListener listener) {
         if (listeners != null) {
             if (Context.DEBUG) {
                 listenersRemoved++;
             }
             listeners.remove(listener);

@@ -90,11 +90,11 @@
      * This method can be called to notify property addition to this object's listeners.
      *
      * @param object The ScriptObject to which property was added.
      * @param prop The property being added.
      */
-    protected final void notifyPropertyAdded(final ScriptObject object, final Property prop) {
+    protected synchronized final void notifyPropertyAdded(final ScriptObject object, final Property prop) {
         if (listeners != null) {
             for (PropertyListener listener : listeners.keySet()) {
                 listener.propertyAdded(object, prop);
             }
         }

@@ -104,11 +104,11 @@
      * This method can be called to notify property deletion to this object's listeners.
      *
      * @param object The ScriptObject from which property was deleted.
      * @param prop The property being deleted.
      */
-    protected final void notifyPropertyDeleted(final ScriptObject object, final Property prop) {
+    protected synchronized final void notifyPropertyDeleted(final ScriptObject object, final Property prop) {
         if (listeners != null) {
             for (PropertyListener listener : listeners.keySet()) {
                 listener.propertyDeleted(object, prop);
             }
         }

@@ -119,11 +119,11 @@
      *
      * @param object The ScriptObject to which property was modified.
      * @param oldProp The old property being replaced.
      * @param newProp The new property that replaces the old property.
      */
-    protected final void notifyPropertyModified(final ScriptObject object, final Property oldProp, final Property newProp) {
+    protected synchronized final void notifyPropertyModified(final ScriptObject object, final Property oldProp, final Property newProp) {
         if (listeners != null) {
             for (PropertyListener listener : listeners.keySet()) {
                 listener.propertyModified(object, oldProp, newProp);
             }
         }