Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Patch
Description
- Use ArrayDeque instead of LinkedList
- Use ThreadLocalRandom instead of Random
- Remove the 'running' flag - use the Thread#join facility to detect if the thread has stopped running. Using a flag can cause race condition issues and is superfluous.
- Make static final variable names in all caps
- General cleanup
This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue.
https://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html