how to know how many elements are currently in a BlockingQueue using Java and Spring -


i have java application , using spring framework.

using beans define queue size set maximum of 5 elements below:

  <bean id="queue1" class="java.util.concurrent.priorityblockingqueue">       <constructor-arg type="int"><value>5</value></constructor-arg>   </bean> 

then pass constructor in java using injection , initialize within constructor. in java have defined , done below:

private final blockingqueue<ordentrabajo> queue; ... this.queue = queue ... 

later, when try queue size in code using:

queue.size() 

it returns 0 instead of 5. why?

also, there possibility obtain number of elements in queue?

the int constructor parameter initial capacity, not number of elements present initially.

priorityblockingqueue.size() returns number of elements present in collection; priorityblockingqueue.remainingcapacity() returns available capacity.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -