395 |
|
// this doc comment is a modified copy of the inherited doc comment, |
396 |
|
// without the reference to unlimited queues. |
397 |
|
/** |
398 |
< |
* Returns the number of elements that this queue can ideally (in |
399 |
< |
* the absence of memory or resource constraints) accept without |
398 |
> |
* Returns the number of additional elements that this queue can ideally |
399 |
> |
* (in the absence of memory or resource constraints) accept without |
400 |
|
* blocking. This is always equal to the initial capacity of this queue |
401 |
|
* less the current <tt>size</tt> of this queue. |
402 |
< |
* <p>Note that you <em>cannot</em> always tell if |
403 |
< |
* an attempt to <tt>add</tt> an element will succeed by |
404 |
< |
* inspecting <tt>remainingCapacity</tt> because it may be the |
405 |
< |
* case that a waiting consumer is ready to <tt>take</tt> an |
406 |
< |
* element out of an otherwise full queue. |
402 |
> |
* |
403 |
> |
* <p>Note that you <em>cannot</em> always tell if an attempt to insert |
404 |
> |
* an element will succeed by inspecting <tt>remainingCapacity</tt> |
405 |
> |
* because it may be the case that another thread is about to |
406 |
> |
* <tt>put</tt> or <tt>take</tt> an element. |
407 |
|
*/ |
408 |
|
public int remainingCapacity() { |
409 |
|
final ReentrantLock lock = this.lock; |