@Test public void testSingleThreadWithElementAdd() throws Exception { final AtomicBoolean stop = new AtomicBoolean(false); Future<Map<Integer, Integer>> future = threadPool.submit(new Callable<Map<Integer, Integer>>() { @Override public Map<Integer, Integer> call() throws Exception { TestWorker worker = new TestWorker(); while (!stop.get()) { worker.process(); } return worker.map; } }); Thread.sleep(500); List<Integer> newList = new ArrayList<Integer>(); newList.addAll(iList); for (int i = 10; i < 15; i++) { newList.add(i); } cList.swapWithList(newList); Thread.sleep(100); stop.set(true); Map<Integer, Integer> result = future.get(); Map<Integer, Integer> subMap = CollectionUtils.filterKeys(result, new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input != null && input < 10; } }); List<Integer> list = new ArrayList<Integer>(subMap.values()); checkValues(list); subMap = CollectionUtils.difference(result, subMap).entriesOnlyOnLeft(); list = new ArrayList<Integer>(subMap.values()); checkValues(list); }
public void swapWithList(Collection<T> newList) { InnerList newInnerList = new InnerList(newList); ref.set(newInnerList); }
CircularList { public void swapWithList(Collection<T> newList) { InnerList newInnerList = new InnerList(newList); ref.set(newInnerList); } }
CircularList { public void swapWithList(Collection<T> newList) { InnerList newInnerList = new InnerList(newList); ref.set(newInnerList); } CircularList(Collection<T> origList); }
CircularList { public void swapWithList(Collection<T> newList) { InnerList newInnerList = new InnerList(newList); ref.set(newInnerList); } CircularList(Collection<T> origList); T getNextElement(); void swapWithList(Collection<T> newList); synchronized void addElement(T element); synchronized void removeElement(T element); List<T> getEntireList(); int getSize(); }
CircularList { public void swapWithList(Collection<T> newList) { InnerList newInnerList = new InnerList(newList); ref.set(newInnerList); } CircularList(Collection<T> origList); T getNextElement(); void swapWithList(Collection<T> newList); synchronized void addElement(T element); synchronized void removeElement(T element); List<T> getEntireList(); int getSize();  }