@Test public void testAdd() { ConcurrentIntSet set = new ConcurrentIntSet(); Random r = new Random(); CountDownLatch latch = new CountDownLatch(1000); createStartAndJoinThreads(new Runnable() { @Override public void run() { latch.countDown(); try { latch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } while (!set.add(r.nextInt())){ } } }, 1000); assertEquals(1000, set.size); }
@Override public boolean add(int key) { lock.lockWrite(); boolean b = super.add(key); lock.unlockWrite(); return b; }
ConcurrentIntSet extends IntSet implements ConcurrentCollection { @Override public boolean add(int key) { lock.lockWrite(); boolean b = super.add(key); lock.unlockWrite(); return b; } }
ConcurrentIntSet extends IntSet implements ConcurrentCollection { @Override public boolean add(int key) { lock.lockWrite(); boolean b = super.add(key); lock.unlockWrite(); return b; } ConcurrentIntSet();  ConcurrentIntSet(int initialCapacity);  ConcurrentIntSet(int initialCapacity, float loadFactor);  ConcurrentIntSet(IntSet set); }
ConcurrentIntSet extends IntSet implements ConcurrentCollection { @Override public boolean add(int key) { lock.lockWrite(); boolean b = super.add(key); lock.unlockWrite(); return b; } ConcurrentIntSet();  ConcurrentIntSet(int initialCapacity);  ConcurrentIntSet(int initialCapacity, float loadFactor);  ConcurrentIntSet(IntSet set); @Override boolean add(int key); @Override void addAll(IntArray array, int offset, int length); @Override void addAll(int[] array, int offset, int length); @Override void addAll(IntSet set); @Override boolean remove(int key); @Override boolean notEmpty(); @Override boolean isEmpty(); @Override void shrink(int maximumCapacity); @Override void clear(int maximumCapacity); @Override void clear(); @Override boolean contains(int key); @Override int first(); @Override void ensureCapacity(int additionalCapacity); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override IntSetIterator iterator(); @Override ReadWriteLock getLock(); }
ConcurrentIntSet extends IntSet implements ConcurrentCollection { @Override public boolean add(int key) { lock.lockWrite(); boolean b = super.add(key); lock.unlockWrite(); return b; } ConcurrentIntSet();  ConcurrentIntSet(int initialCapacity);  ConcurrentIntSet(int initialCapacity, float loadFactor);  ConcurrentIntSet(IntSet set); @Override boolean add(int key); @Override void addAll(IntArray array, int offset, int length); @Override void addAll(int[] array, int offset, int length); @Override void addAll(IntSet set); @Override boolean remove(int key); @Override boolean notEmpty(); @Override boolean isEmpty(); @Override void shrink(int maximumCapacity); @Override void clear(int maximumCapacity); @Override void clear(); @Override boolean contains(int key); @Override int first(); @Override void ensureCapacity(int additionalCapacity); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override IntSetIterator iterator(); @Override ReadWriteLock getLock();  }