public class SyncQueue<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
defaultInitialCapacity |
static int |
defaultMaxLength |
| Constructor and Description |
|---|
SyncQueue()
Construct a
SyncQueue with the default initial capacity. |
SyncQueue(int initialCapacity)
Construct a
SyncQueue with the specified initial capacity. |
SyncQueue(int initialCapacity,
int maxLength)
Construct a
SyncQueue with the specified initial capacity and maximum size. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T object)
Add an object to the end of the queue and wake up all threads currently waiting for this
queue.
|
boolean |
addUnique(T object)
Add an object to the end of the queue and wake up all threads currently waiting for this
queue.
|
T |
get()
Get the next object from the queue, blocking if none is available.
|
int |
getMaxLength()
Get the maximum queue length.
|
int |
getSize()
Determine the current length of the queue.
|
boolean |
insert(T object)
Insert an object at the beginning of the queue and wake up all threads currently waiting
for this queue.
|
boolean |
insertUnique(T object)
Insert an object at the beginning of the queue and wake up all threads currently waiting
for this queue.
|
boolean |
remove(T object)
Remove the specified object from the queue.
|
void |
setMaxLength(int maxLength)
Get the maximum queue length.
|
public static final int defaultInitialCapacity
public static final int defaultMaxLength
public SyncQueue(int initialCapacity,
int maxLength)
SyncQueue with the specified initial capacity and maximum size.initialCapacity - the initial capacity of the queuemaxLength - the maximum length of the queuepublic SyncQueue(int initialCapacity)
SyncQueue with the specified initial capacity.initialCapacity - the initial capacity of the queuepublic SyncQueue()
SyncQueue with the default initial capacity.public boolean add(T object)
object - the object to be addedtrue if the operation was successfulpublic boolean addUnique(T object)
object - the object to be addedtrue if the operation was successfulpublic boolean insert(T object)
object - the object to be addedtrue if the operation was successfulpublic boolean insertUnique(T object)
object - the object to be addedtrue if the operation was successfulpublic boolean remove(T object)
object - the object to be removedtrue if the object was removedpublic T get()
null if the thread is interrupted.nullpublic int getSize()
public int getMaxLength()
public void setMaxLength(int maxLength)
maxLength - the maximum queue lengthCopyright © 2020. All rights reserved.