How thread-safe is enum in java?

Posted by portoalet on Stack Overflow See other posts from Stack Overflow or by portoalet
Published on 2010-03-28T04:14:29Z Indexed on 2010/03/28 4:23 UTC
Read the original article Hit count: 414

Filed under:
|
|

Hi,

How thread-safe is enum in java? I am implementing a Singleton using enum (as per Bloch's Effective Java), should I worry at all about thread safety for my singleton enum? Is there a way to prove or disprove that it is thread safe?

// Enum singleton - the preferred approach
public enum Elvis { 
    INSTANCE;
    public void leaveTheBuilding() { ... }
}

Thanks

© Stack Overflow or respective owner

Related posts about enums

Related posts about java