本文整理汇总了Java中java.util.ConcurrentModificationException类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentModificationException类的具体用法?Java ConcurrentModificationException怎么用?Java ConcurrentModificationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentModificationException类属于java.util包,在下文中一共展示了ConcurrentModificationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remove
import java.util.ConcurrentModificationException; //导入依赖的package包/类
public void remove() {
if (lastReturned == null) {
throw new IllegalStateException();
}
if (fast) {
synchronized (WeakFastHashMap.this) {
if (expected != map) {
throw new ConcurrentModificationException();
}
WeakFastHashMap.this.remove(lastReturned.getKey());
lastReturned = null;
expected = map;
}
} else {
iterator.remove();
lastReturned = null;
}
}
示例2: forEachRemaining
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@Override
public void forEachRemaining(Consumer<? super T> action) {
Objects.requireNonNull(action);
Object eol = endOfList;
Object p;
int n;
if ((n = getEst()) > 0 && (p = current) != eol) {
current = eol;
est = 0;
do {
T item = getNodeItem(p);
p = getNextNode(p);
action.accept(item);
} while (p != eol && --n > 0);
}
if (expectedModCount != getModCount(list)) {
throw new ConcurrentModificationException();
}
}
示例3: next
import java.util.ConcurrentModificationException; //导入依赖的package包/类
/**
* Returns the next element in the iteration.
* @return The next element in the iteration.
* @throws ConcurrentModificationException If collection is updated while iterating through.
* @throws NoSuchElementException If the iteration has no more elements.
*/
@Override
public TableEntry next() {
if(expModificationCount != modificationCount) {
throw new ConcurrentModificationException("Collection is updated while iterating through!");
}
for(; currentIndex < table.length; currentIndex++) {
if(table[currentIndex] != null) {
if(current == null) {
current = lastReturned = table[currentIndex];
current = current.next;
} else {
lastReturned = current;
current = current.next;
}
if(current == null) {
currentIndex++;
}
count++;
return lastReturned;
}
}
throw new NoSuchElementException("There is no more elements in collection!");
}
示例4: statusSolutionInfo
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@Override
public Map<String,String> statusSolutionInfo() {
if (isPassivated())
return (iBestSolutionInfoBeforePassivation == null ? iCurrentSolutionInfoBeforePassivation : iBestSolutionInfoBeforePassivation);
Lock lock = currentSolution().getLock().readLock();
lock.lock();
try {
Map<String,String> info = super.currentSolution().getBestInfo();
try {
Solution<V, T> solution = getWorkingSolution();
if (info == null || getSolutionComparator().isBetterThanBestSolution(solution))
info = solution.getModel().getInfo(solution.getAssignment());
} catch (ConcurrentModificationException e) {}
return info;
} finally {
lock.unlock();
}
}
示例5: remove
import java.util.ConcurrentModificationException; //导入依赖的package包/类
public void remove() {
if (lastRet < 0) {
throw new IllegalStateException();
}
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
try {
UnsafeList.this.remove(lastRet);
index = lastRet;
lastRet = -1;
expectedModCount = modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
}
示例6: replaceAll
import java.util.ConcurrentModificationException; //导入依赖的package包/类
public void replaceAll(UnaryOperator<E> operator) {
if (operator == null) throw new NullPointerException();
final ReentrantLock lock = l.lock;
lock.lock();
try {
int lo = offset;
int hi = offset + size;
Object[] elements = expectedArray;
if (l.getArray() != elements)
throw new ConcurrentModificationException();
int len = elements.length;
if (lo < 0 || hi > len)
throw new IndexOutOfBoundsException();
Object[] newElements = Arrays.copyOf(elements, len);
for (int i = lo; i < hi; ++i) {
@SuppressWarnings("unchecked") E e = (E) elements[i];
newElements[i] = operator.apply(e);
}
l.setArray(expectedArray = newElements);
} finally {
lock.unlock();
}
}
示例7: next
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@Override
public Long next() {
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
int length = values.length;
if (index >= length) {
lastReturned = -2;
throw new NoSuchElementException();
}
lastReturned = index;
for (index += 1; index < length && (values[index] == FREE || values[index] == REMOVED); index++) {
// This is just to drive the index forward to the next valid entry
}
if (values[lastReturned] == FREE) {
return FREE;
} else {
return values[lastReturned];
}
}
示例8: toString
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@Override
public String toString() {
String ret = super.toString();
if (this.responses.isEmpty() == false) {
ret += "\n-------------\n";
String debug = "";
while (true) {
try {
debug = StringUtil.join("\n", this.responses);
} catch (ConcurrentModificationException ex) {
continue;
}
break;
}
ret += debug;
}
return (ret);
}
示例9: doBuildCache
import java.util.ConcurrentModificationException; //导入依赖的package包/类
private BridgeTable<String> doBuildCache(String tenantId)
{
List<AuthorityBridgeLink> links = authorityBridgeDAO.getAuthorityBridgeLinks();
BridgeTable<String> bridgeTable = new BridgeTable<String>();
try
{
for (AuthorityBridgeLink link : links)
{
bridgeTable.addLink(link.getParentName(), link.getChildName());
}
}
catch (ConcurrentModificationException e)
{
// Explain exception
checkCyclic(links);
// If cyclic groups is not the cause then rethrow
throw e;
}
return bridgeTable;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AuthorityBridgeTableAsynchronouslyRefreshedCache.java
示例10: ensureNext
import java.util.ConcurrentModificationException; //导入依赖的package包/类
private void ensureNext() {
if (trackModification && modification != iterModification) {
throw new ConcurrentModificationException("modification=" + modification
+ " != iterModification = " + iterModification);
}
if (next != null) {
return;
}
if (cur == null) {
return;
}
next = cur.getNext();
if (next == null) {
next = nextNonemptyEntry();
}
}
示例11: remove
import java.util.ConcurrentModificationException; //导入依赖的package包/类
/**
* Removes the last entry returned by the iterator.
* Invoking this method more than once for a single entry
* will leave the underlying data structure in a confused
* state.
*/
public void remove() {
if (_expectedSize != _hash.size()) {
throw new ConcurrentModificationException();
}
// Disable auto compaction during the remove. This is a workaround for bug 1642768.
try {
_hash.tempDisableAutoCompaction();
_hash.removeAt(_index);
}
finally {
_hash.reenableAutoCompaction( false );
}
_expectedSize--;
}
示例12: next
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@Override
public T next() {
if (modification != startModification) {
throw new ConcurrentModificationException("modification="
+ modification + " != startModification = " + startModification);
}
if (next == null) {
throw new NoSuchElementException();
}
final T e = next.element;
// find the next element
final LinkedElement<T> n = next.next;
next = n != null ? n : nextNonemptyEntry();
return e;
}
示例13: testPutAbsentConcurrentWithValueIteration
import java.util.ConcurrentModificationException; //导入依赖的package包/类
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_PUT})
@CollectionSize.Require(absent = ZERO)
public void testPutAbsentConcurrentWithValueIteration() {
try {
Iterator<V> iterator = getMap().values().iterator();
put(e3());
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
}
}
示例14: retainAll
import java.util.ConcurrentModificationException; //导入依赖的package包/类
public boolean retainAll(Collection<?> c) {
if (c == null) throw new NullPointerException();
boolean removed = false;
final ReentrantLock lock = l.lock;
lock.lock();
try {
int n = size;
if (n > 0) {
int lo = offset;
int hi = offset + n;
Object[] elements = expectedArray;
if (l.getArray() != elements)
throw new ConcurrentModificationException();
int len = elements.length;
if (lo < 0 || hi > len)
throw new IndexOutOfBoundsException();
int newSize = 0;
Object[] temp = new Object[n];
for (int i = lo; i < hi; ++i) {
Object element = elements[i];
if (c.contains(element))
temp[newSize++] = element;
}
if (newSize != n) {
Object[] newElements = new Object[len - n + newSize];
System.arraycopy(elements, 0, newElements, 0, lo);
System.arraycopy(temp, 0, newElements, lo, newSize);
System.arraycopy(elements, hi, newElements,
lo + newSize, len - hi);
size = newSize;
removed = true;
l.setArray(expectedArray = newElements);
}
}
} finally {
lock.unlock();
}
return removed;
}
示例15: reset
import java.util.ConcurrentModificationException; //导入依赖的package包/类
public void reset() {
setIncremental(true);
for (Edge edge : super.getEdges())
super.removeEdge(edge);
Collection<Vertex> vertices = super.getVertices();
while (!vertices.isEmpty()) {
try {
for (Vertex vertex : vertices)
super.removeVertex(vertex);
} catch (ConcurrentModificationException e) {
}
}
update(0);
}