本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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) {}
}
示例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();
}
}
}