NotificationEmitterSupport.java 文件源码

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

项目:OpenJSharp 作者:
public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
        throws ListenerNotFoundException {

    boolean found = false;

    synchronized (listenerLock) {
        List<ListenerInfo> newList = new ArrayList<>(listenerList);
        final int size = newList.size();
        for (int i = 0; i < size; i++) {
            ListenerInfo li =  newList.get(i);

            if (li.listener == listener) {
                found = true;
                if (li.filter == filter
                    && li.handback == handback) {
                    newList.remove(i);
                    listenerList = newList;
                    return;
                }
            }
        }
    }

    if (found) {
        /* We found this listener, but not with the given filter
         * and handback.  A more informative exception message may
         * make debugging easier.  */
        throw new ListenerNotFoundException("Listener not registered " +
                                            "with this filter and " +
                                            "handback");
    } else {
        throw new ListenerNotFoundException("Listener not registered");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号