How is ArrayDeque faster than stack?

ArrayDeque is part of the Java Collections Framework and is not written to be inherently thread safe.

Stack, together with Vector and Hashtable came with Java 1.0 and were implemented with thread safe operations (because it seemed like a good idea at the time). Acquiring and releasing thread locks is relatively expensive time wise, hence those data structures will be much slower than their compatriots in the JCF.


Because most operations don't require the array to resize, particularly once the queue has reached a stable size and isn't growing any more.

Every time you add an item Stack has to allocate new objects update the links, etc.

ArrayDeque just needs to put an object in the array and update an index.