本文整理汇总了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();
}
}
}