当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentModificationException类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:19,代码来源:WeakFastHashMap.java

示例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();
    }
}
 
开发者ID:retrostreams,项目名称:android-retrostreams,代码行数:20,代码来源:LinkedListSpliterator.java

示例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!");
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:30,代码来源:SimpleHashtable.java

示例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();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:AbstractSolver.java

示例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();
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:19,代码来源:UnsafeList.java

示例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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:CopyOnWriteArrayList.java

示例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];
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:LongHashSet.java

示例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);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:19,代码来源:LocalInitQueueCallback.java

示例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();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:LightWeightGSet.java

示例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--;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:23,代码来源:THashPrimitiveIterator.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:LightWeightHashSet.java

示例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
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:MapPutTester.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:CopyOnWriteArrayList.java

示例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);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:16,代码来源:ContestSimulation.java


注:本文中的java.util.ConcurrentModificationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。