T
- the type of the list elementpublic class ConcurrentListBuilder<T> extends Object
Note that this class is thread-safe for adding elements only. It is not thread-safe for adding
elements concurrent with calling toList()
, with the possible result being that some
elements in the returned list may have un-assigned values.
To avoid thread contention, the initial size of the list should be specified so as to avoid the need to resize the internal array when its size is exceeded.
Constructor and Description |
---|
ConcurrentListBuilder() |
ConcurrentListBuilder(Collection<T> other) |
ConcurrentListBuilder(int initialSize) |
public ConcurrentListBuilder()
public ConcurrentListBuilder(int initialSize)
public ConcurrentListBuilder(Collection<T> other)
public int add(T item)
Blocking on add operations only occurs when the list array needs to be grown.
item
- The item to addNullPointerException
- on attempt to add null to the listpublic int size()
Copyright © 2011-2015 IBM. All Rights Reserved.