本文整理了Java中java.util.ConcurrentModificationException
类的一些代码示例,展示了ConcurrentModificationException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentModificationException
类的具体详情如下:
包路径:java.util.ConcurrentModificationException
类名称:ConcurrentModificationException
[英]An ConcurrentModificationException is thrown when a Collection is modified and an existing iterator on the Collection is used to modify the Collection as well.
[中]修改集合时会引发ConcurrentModificationException,并且集合上的现有迭代器也用于修改集合。
代码示例来源:origin: google/guava
private void checkForConcurrentModification() {
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
}
};
代码示例来源:origin: Netflix/EVCache
public void run() {
while (running) {
try {
handleIO();
} catch (IOException e) {
if (log.isDebugEnabled()) log.debug(e.getMessage(), e);
} catch (CancelledKeyException e) {
if (log.isDebugEnabled()) log.debug(e.getMessage(), e);
} catch (ClosedSelectorException e) {
if (log.isDebugEnabled()) log.debug(e.getMessage(), e);
} catch (IllegalStateException e) {
if (log.isDebugEnabled()) log.debug(e.getMessage(), e);
} catch (ConcurrentModificationException e) {
if (log.isDebugEnabled()) log.debug(e.getMessage(), e);
} catch (Throwable e) {
log.error("SEVERE EVCACHE ISSUE.", e);// This ensures the thread
// doesn't die
}
}
if (log.isDebugEnabled()) log.debug(toString() + " : Shutdown");
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void forEachRemaining(@Nonnull Consumer<? super Map.Entry<Double, Double>> action) {
if (action == null)
throw new java.lang.NullPointerException();
long[] tab = this.tab;
int nextI = nextIndex;
for (int i = nextI; i >= 0; i -= 2) {
long key;
if ((key = tab[i]) < FREE_BITS) {
action.accept(new ImmutableEntry(key, tab[i + 1]));
}
}
if (nextI != nextIndex) {
throw new java.util.ConcurrentModificationException();
}
nextIndex = -1;
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void forEachRemaining(Consumer<? super Double> action) {
if (action == null)
throw new java.lang.NullPointerException();
long[] tab = this.tab;
int nextI = nextIndex;
for (int i = nextI; i >= 0; i -= 2) {
if (tab[i] < FREE_BITS) {
action.accept(Double.longBitsToDouble(tab[i + 1]));
}
}
if (nextI != nextIndex) {
throw new java.util.ConcurrentModificationException();
}
nextIndex = -1;
}
代码示例来源:origin: qcri/Arabesque
@Override
public void forEachForward(@Nonnull IntConsumer intConsumer) {
int localNumElements = numElements;
for (int i = index; i < localNumElements; ++i) {
intConsumer.accept(backingArray[i]);
}
if(localNumElements != numElements) {
throw new ConcurrentModificationException();
} else {
this.index = numElements;
}
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void setValue(int value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putInt(tab, LONG_BASE + INT_VALUE_OFFSET + (((long) (index)) << LONG_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void setValue(char value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putChar(tab, INT_BASE + CHAR_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void setValue(short value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putShort(tab, INT_BASE + SHORT_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: net.openhft/koloboke-impl-jdk8
@Override
public void setValue(byte value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putByte(tab, CHAR_BASE + BYTE_VALUE_OFFSET + (((long) (index)) << CHAR_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: streamsupport/streamsupport
private static <E> E getNodeItem(Object node) {
if (node == null) {
throw new ConcurrentModificationException();
}
return (E) U.getObject(node, NODE_ITEM_OFF);
}
代码示例来源:origin: oblac/jodd
/**
* http://code.google.com/p/jodd/issues/detail?id=4
*/
@Test
void testPutGetAndPrune() throws InterruptedException {
LFUCache<String, String> lfuCache = new LFUCache<>(2, 0);
lfuCache.put("1", "value");
assertFalse(lfuCache.isFull());
lfuCache.put("2", "value");
assertTrue(lfuCache.isFull());
lfuCache.get("2");
lfuCache.get("2");
assertEquals(2, lfuCache.size());
Semaphore semaphore = new Semaphore(2);
Thread1 t1 = new Thread1(semaphore, lfuCache);
Thread2 t2 = new Thread2(semaphore, lfuCache);
t1.start();
t2.start();
semaphore.acquire();
if (t1.exception != null) {
t1.exception.printStackTrace();
}
assertNull(t1.exception);
if (t2.exception != null) {
t2.exception.printStackTrace();
}
assertNull(t2.exception);
}
代码示例来源:origin: net.openhft/koloboke-impl-jdk8
@Override
public void forEachRemaining(@Nonnull Consumer<? super Map.Entry<Double, Double>> action) {
if (action == null)
throw new java.lang.NullPointerException();
long[] tab = this.tab;
int nextI = nextIndex;
for (int i = nextI; i >= 0; i -= 2) {
long key;
if ((key = tab[i]) < FREE_BITS) {
action.accept(new ImmutableEntry(key, tab[i + 1]));
}
}
if (nextI != nextIndex) {
throw new java.util.ConcurrentModificationException();
}
nextIndex = -1;
}
代码示例来源:origin: net.openhft/koloboke-impl-jdk8
@Override
public void forEachRemaining(Consumer<? super Double> action) {
if (action == null)
throw new java.lang.NullPointerException();
long[] tab = this.tab;
int nextI = nextIndex;
for (int i = nextI; i >= 0; i -= 2) {
if (tab[i] < FREE_BITS) {
action.accept(Double.longBitsToDouble(tab[i + 1]));
}
}
if (nextI != nextIndex) {
throw new java.util.ConcurrentModificationException();
}
nextIndex = -1;
}
代码示例来源:origin: qcri/Arabesque
@Override
public void forEachRemaining(@Nonnull IntConsumer intConsumer) {
int localNumElements = numElements;
for (int i = index + 1; i < localNumElements - 1; ++i) {
intConsumer.accept(backingArray[i]);
}
if (localNumElements != numElements) {
throw new ConcurrentModificationException();
} else {
index = numElements - 1;
}
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk8
@Override
public void setValue(float value) {
if (curKey != FREE_BITS) {
if (expectedModCount == modCount()) {
U.putInt(tab, LONG_BASE + FLOAT_VALUE_OFFSET + (((long) (index)) << LONG_SCALE_SHIFT), Float.floatToIntBits(value));
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: net.openhft/koloboke-impl-jdk8
@Override
public void setValue(char value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putChar(tab, INT_BASE + CHAR_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: net.openhft/koloboke-impl-jdk8
@Override
public void setValue(short value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putShort(tab, INT_BASE + SHORT_VALUE_OFFSET + (((long) (index)) << INT_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: com.koloboke/koloboke-impl-jdk6-7
@Override
public void setValue(byte value) {
if (curKey != free) {
if (expectedModCount == modCount()) {
U.putByte(tab, CHAR_BASE + BYTE_VALUE_OFFSET + (((long) (index)) << CHAR_SCALE_SHIFT), value);
} else {
throw new java.util.ConcurrentModificationException();
}
} else {
throw new java.lang.IllegalStateException();
}
}
代码示例来源:origin: net.sourceforge.streamsupport/android-retrostreams
private static Object getNextNode(Object node) {
if (node == null) {
throw new ConcurrentModificationException();
}
return U.getObject(node, NODE_NEXT_OFF);
}
代码示例来源:origin: UniversaBlockchain/universa
public void traceErrors() {
try {
for (ErrorRecord er : errors) {
System.out.println("Error: " + er);
}
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!