當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。