If you do not need to force the use of queue capacity , you can simply use LinkedList
. It implements the Queue
interface that you really need.
Use it as follows:
Queue<EnumClass> queue = new LinkedList<EnumClass>(); queue.offer(newObj); takenObj = queue.poll();
If you need to limit the size , then ArrayBlockingQueue
would be a good option, since there would be no additional creation of an internal object (collection supported by the array).
Queue<EnumClass> queue = new ArrayBlockingQueue<EnumClass>(capacity);
However, using it with the Queue
interface would be a good idea. This way you can change the actual implementations as you wish.
source share