@Test public void testAddItems() { ConcurrentByteArray a = new ConcurrentByteArray(); CountDownLatch latch = new CountDownLatch(100); createStartAndJoinThreads(new Runnable() { @Override public void run() { latch.countDown(); try { latch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } for (int i = 0; i < 100; i++) { a.add((byte)(i % 256 - 128)); } } }, 100); assertEquals(a.size, 10*1000); }
@Override public void add(byte value) { lock.lockWrite(); super.add(value); lock.unlockWrite(); }
ConcurrentByteArray extends ByteArray implements ConcurrentCollection { @Override public void add(byte value) { lock.lockWrite(); super.add(value); lock.unlockWrite(); } }
ConcurrentByteArray extends ByteArray implements ConcurrentCollection { @Override public void add(byte value) { lock.lockWrite(); super.add(value); lock.unlockWrite(); } ConcurrentByteArray();  ConcurrentByteArray(int capacity);  ConcurrentByteArray(boolean ordered, int capacity);  ConcurrentByteArray(ByteArray array);  ConcurrentByteArray(byte[] array);  ConcurrentByteArray(boolean ordered, byte[] array, int startIndex, int count); }
ConcurrentByteArray extends ByteArray implements ConcurrentCollection { @Override public void add(byte value) { lock.lockWrite(); super.add(value); lock.unlockWrite(); } ConcurrentByteArray();  ConcurrentByteArray(int capacity);  ConcurrentByteArray(boolean ordered, int capacity);  ConcurrentByteArray(ByteArray array);  ConcurrentByteArray(byte[] array);  ConcurrentByteArray(boolean ordered, byte[] array, int startIndex, int count); @Override void add(byte value); @Override void add(byte value1, byte value2); @Override void add(byte value1, byte value2, byte value3); @Override void add(byte value1, byte value2, byte value3, byte value4); @Override void addAll(byte[] array, int offset, int length); @Override byte get(int index); @Override void set(int index, byte value); @Override void insert(int index, byte value); @Override void swap(int first, int second); @Override void addAll(ByteArray array, int offset, int length); @Override int removeIndex(int index); @Override void removeRange(int start, int end); @Override byte pop(); @Override byte peek(); @Override byte first(); @Override boolean notEmpty(); @Override boolean isEmpty(); @Override void clear(); @Override byte[] shrink(); @Override void incr(int index, byte value); @Override void mul(int index, byte value); @Override boolean contains(byte value); @Override int indexOf(byte value); @Override int lastIndexOf(byte value); @Override boolean removeValue(byte value); @Override boolean removeAll(ByteArray array); @Override void sort(); @Override byte[] ensureCapacity(int additionalCapacity); @Override byte[] setSize(int newSize); @Override void reverse(); @Override void shuffle(); @Override void truncate(int newSize); @Override byte random(); @Override byte[] toArray(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString(); @Override String toString(String separator); @Override ReadWriteLock getLock(); }
ConcurrentByteArray extends ByteArray implements ConcurrentCollection { @Override public void add(byte value) { lock.lockWrite(); super.add(value); lock.unlockWrite(); } ConcurrentByteArray();  ConcurrentByteArray(int capacity);  ConcurrentByteArray(boolean ordered, int capacity);  ConcurrentByteArray(ByteArray array);  ConcurrentByteArray(byte[] array);  ConcurrentByteArray(boolean ordered, byte[] array, int startIndex, int count); @Override void add(byte value); @Override void add(byte value1, byte value2); @Override void add(byte value1, byte value2, byte value3); @Override void add(byte value1, byte value2, byte value3, byte value4); @Override void addAll(byte[] array, int offset, int length); @Override byte get(int index); @Override void set(int index, byte value); @Override void insert(int index, byte value); @Override void swap(int first, int second); @Override void addAll(ByteArray array, int offset, int length); @Override int removeIndex(int index); @Override void removeRange(int start, int end); @Override byte pop(); @Override byte peek(); @Override byte first(); @Override boolean notEmpty(); @Override boolean isEmpty(); @Override void clear(); @Override byte[] shrink(); @Override void incr(int index, byte value); @Override void mul(int index, byte value); @Override boolean contains(byte value); @Override int indexOf(byte value); @Override int lastIndexOf(byte value); @Override boolean removeValue(byte value); @Override boolean removeAll(ByteArray array); @Override void sort(); @Override byte[] ensureCapacity(int additionalCapacity); @Override byte[] setSize(int newSize); @Override void reverse(); @Override void shuffle(); @Override void truncate(int newSize); @Override byte random(); @Override byte[] toArray(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString(); @Override String toString(String separator); @Override ReadWriteLock getLock();  }