DEV Community

Thu Huynh
Thu Huynh

Posted on

[Java 8] Should not use ENUM instance as a member of a class

Description:
Sometime you want to use an ENUM instance as a member of a class for some reasons.

Issue:
As you may not know, ENUM instance is a global variable so if we make it as a member of a class you may know that variable is shared for all other threads.
Specially, when the ENUM instance has a mutable variable, it will create an issue about dirty read.

Solution:
Don't use mutable variable in the ENUM class.

Top comments (0)