SharedClassObject.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:incubator-netbeans 作者:
/** Adds the specified property change listener to receive property
 * change events from this object.
 * @param         l the property change listener
 */
public final void addPropertyChangeListener(PropertyChangeListener l) {
    boolean noListener;

    synchronized (getLock()) {
        //      System.out.println ("added listener: " + l + " to: " + getClass ()); // NOI18N
        PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);

        if (supp == null) {
            //        System.out.println ("Creating support"); // NOI18N
            putProperty(PROP_SUPPORT, supp = new PropertyChangeSupport(this));
        }

        noListener = !supp.hasListeners(null);
        supp.addPropertyChangeListener(l);
    }

    if (noListener) {
        addNotifySuper = false;
        addNotify();

        if (!addNotifySuper) {
            // [PENDING] theoretical race condition for this warning if listeners are added
            // and removed very quickly from two threads, I guess, and addNotify() impl is slow
            String msg = "You must call super.addNotify() from " + getClass().getName() + ".addNotify()"; // NOI18N
            err.warning(msg);
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号