Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If multiple threads are going to be accessing the queue then consider using an <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ArrayBlockingQueue.html" rel="noreferrer"><code>ArrayBlockingQueue</code></a>. Otherwise take a look at <a href="http://java.sun.com/javase/6/docs/api/java/util/ArrayDeque.html" rel="noreferrer"><code>ArrayDeque</code></a>. From the <code>ArrayDeque</code> API:</p> <blockquote> <p>This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue.</p> </blockquote> <p>Specifically an array-based queue implementation reduces the need to resize the underlying array if the existing array has sufficient capacity, thus making additions to the queue generally faster than <code>LinkedList</code>. Be aware that <code>ArrayBlockingQueue</code> is a bounded implementation whereas <code>ArrayDeque</code> will resize as required.</p> <p>The flip-side is that <code>LinkedList</code> will typically provide a much more compact representation, particularly in cases where your queue grows and shrinks by a large amount. For example, if you added 10,000,000 elements to an <code>ArrayDeque</code> and then removed 9,999,999 elements, the underlying array would still be of length 10,000,000 whereas a <code>LinkedList</code> would not suffer from this problem.</p> <p>In reality, for single-threaded access to a non-blocking queue I tend to favour <code>LinkedList</code>. I imagine the performance differences are so negligable you wouldn't notice the difference anyway.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload