public class MemorySafeLinkedBlockingQueue<E> extends VariableLinkedBlockingQueue<E>
LinkedBlockingQueue.| 限定符和类型 | 字段和说明 |
|---|---|
static int |
THE_16_MB |
| 构造器和说明 |
|---|
MemorySafeLinkedBlockingQueue() |
MemorySafeLinkedBlockingQueue(Collection<? extends E> c,
int maxFreeMemory) |
MemorySafeLinkedBlockingQueue(int maxFreeMemory) |
MemorySafeLinkedBlockingQueue(int capacity,
int maxFreeMemory) |
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getMaxFreeMemory()
get the max free memory.
|
boolean |
hasRemainedMemory()
determine if there is any remaining free memory.
|
boolean |
offer(E e)
Inserts the specified element at the tail of this queue if it is
possible to do so immediately without exceeding the queue's capacity,
returning
true upon success and false if this queue
is full. |
boolean |
offer(E e,
long timeout,
TimeUnit unit)
Inserts the specified element at the tail of this queue, waiting if
necessary up to the specified wait time for space to become available.
|
void |
put(E e)
Inserts the specified element at the tail of this queue, waiting if
necessary for space to become available.
|
void |
setMaxFreeMemory(int maxFreeMemory)
set the max free memory.
|
clear, contains, drainTo, drainTo, iterator, peek, poll, poll, remainingCapacity, remove, setCapacity, size, spliterator, take, toArray, toArray, toStringadd, addAll, element, removecontainsAll, isEmpty, removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddaddAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, streampublic static final int THE_16_MB
public MemorySafeLinkedBlockingQueue()
public MemorySafeLinkedBlockingQueue(int maxFreeMemory)
public MemorySafeLinkedBlockingQueue(int capacity,
int maxFreeMemory)
public MemorySafeLinkedBlockingQueue(Collection<? extends E> c, int maxFreeMemory)
public void setMaxFreeMemory(int maxFreeMemory)
maxFreeMemory - the max free memorypublic int getMaxFreeMemory()
public boolean hasRemainedMemory()
public void put(E e) throws InterruptedException
VariableLinkedBlockingQueueput 在接口中 BlockingQueue<E>put 在类中 VariableLinkedBlockingQueue<E>InterruptedExceptionpublic boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
VariableLinkedBlockingQueueoffer 在接口中 BlockingQueue<E>offer 在类中 VariableLinkedBlockingQueue<E>true if successful, or false if
the specified waiting time elapses before space is availableInterruptedExceptionpublic boolean offer(E e)
VariableLinkedBlockingQueuetrue upon success and false if this queue
is full.
When using a capacity-restricted queue, this method is generally
preferable to method add, which can fail to
insert an element only by throwing an exception.offer 在接口中 BlockingQueue<E>offer 在接口中 Queue<E>offer 在类中 VariableLinkedBlockingQueue<E>Copyright © 2025. All rights reserved.