Can we have an AtomicEnum in Java?

Viewed 9088

Today I saw this utility class for AtomicEnum but I wonder if it is possible to have an atomic enum why it is not included in Java standard libraries? In fact I have so much doubt if it can be really atomic and if this utility class works.

The AtomicEnum class is this

  1. How can I examine if it does the operations atomically?
  2. Is there a tool for seeing the compiled code and be sure that it does really all in only one machine instruction?
  3. Is it possible to discover it from the code?
  4. So if this Atomic enum works, I can have an attribute AtomicEnum and it will be possible to use it safely without volatile keyword and synchronized getters and setters?
4 Answers
Related