当前位置: 首页>>代码示例>>Java>>正文


Java CopyOnWriteArrayList.iterator方法代码示例

本文整理汇总了Java中java.util.concurrent.CopyOnWriteArrayList.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java CopyOnWriteArrayList.iterator方法的具体用法?Java CopyOnWriteArrayList.iterator怎么用?Java CopyOnWriteArrayList.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.CopyOnWriteArrayList的用法示例。


在下文中一共展示了CopyOnWriteArrayList.iterator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: abortAllJobs

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
private synchronized void abortAllJobs(String reason) {
    // Active jobs will be changing as jobs are completed. Act on snapshot of jobs that we know.
    CopyOnWriteArrayList<Job> activeJobsCopy = new CopyOnWriteArrayList<>(this.activeJobs);
    Iterator<Job> it = activeJobsCopy.iterator();
    while (it.hasNext()) {
        Job job = it.next();
        job.abort(reason);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:10,代码来源:JobEngine.java

示例2: getJobByTask

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
public synchronized Job getJobByTask(Task task) {
    CopyOnWriteArrayList<Job> activeJobsCopy = new CopyOnWriteArrayList<>(this.activeJobs);
    Iterator<Job> it = activeJobsCopy.iterator();
    while (it.hasNext()) {
        Job job = it.next();
        for (TaskNode taskNode : job.getTaskGraph().getGraph().getNodes()) {
            if (taskNode.getTask() == task) {
                return job;
            }
        }
    }
    return null;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:14,代码来源:JobEngine.java

示例3: postSingleEventForEventType

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
private boolean postSingleEventForEventType(Object event, PostingThreadState postingState, Class<?> eventClass) {
    synchronized (this) {
        CopyOnWriteArrayList<Subscription> subscriptions = (CopyOnWriteArrayList) this.subscriptionsByEventType.get(eventClass);
    }
    if (subscriptions == null || subscriptions.isEmpty()) {
        return false;
    }
    Iterator i$ = subscriptions.iterator();
    loop0:
    while (i$.hasNext()) {
        Subscription subscription = (Subscription) i$.next();
        postingState.event = event;
        postingState.subscription = subscription;
        boolean z = false;
        try {
            postToSubscription(subscription, event, postingState.isMainThread);
            z = postingState.canceled;
            continue;
        } finally {
            postingState.event = null;
            postingState.subscription = null;
            postingState.canceled = false;
        }
        if (z) {
            break loop0;
        }
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:30,代码来源:EventBus.java

示例4: testIteratorRemove

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
/**
 * iterator.remove throws UnsupportedOperationException
 */
public void testIteratorRemove() {
    CopyOnWriteArrayList full = populatedArray(SIZE);
    Iterator it = full.iterator();
    it.next();
    try {
        it.remove();
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:CopyOnWriteArrayListTest.java

示例5: removeMethodsFromMap

import java.util.concurrent.CopyOnWriteArrayList; //导入方法依赖的package包/类
/**
 * remove subscriber methods from map
 */
public void removeMethodsFromMap(Object subscriber) {
    Iterator<CopyOnWriteArrayList<XulSubscription>> iterator =
            _subscriberMap.values().iterator();
    while (iterator.hasNext()) {
        CopyOnWriteArrayList<XulSubscription> subscriptions = iterator.next();
        if (subscriptions != null) {
            List<XulSubscription> foundSubscriptions = new LinkedList<XulSubscription>();
            Iterator<XulSubscription> subIterator = subscriptions.iterator();
            while (subIterator.hasNext()) {
                XulSubscription xulSubscription = subIterator.next();
                // 获取引用
                Object cacheObject = xulSubscription.getSubscriber();
                if ((cacheObject == null)
                    || cacheObject.equals(subscriber)) {
                    xulSubscription.clearXulMessages();
                    foundSubscriptions.add(xulSubscription);
                }
            }

            // 移除该subscriber的相关的Subscription
            subscriptions.removeAll(foundSubscriptions);
        }

        // 如果针对某个Msg的订阅者数量为空了,那么需要从map中清除
        if (subscriptions == null || subscriptions.size() == 0) {
            iterator.remove();
        }
    }
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:33,代码来源:XulSubscriberMethodHunter.java


注:本文中的java.util.concurrent.CopyOnWriteArrayList.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。