Java Singleton Pattern

  • + 1 comment

    I don't see any problem with synchronization, everything's correct here.

    | "The problem with above serialized singleton class is that whenever we deserialize it, it will create a new instance of the class" - this is universal problem, one should not serialize singleton with default serializer :)

    EDIT: readResolve() looks like a dirty workaround, but it really should work!

    • + 1 comment

      true... but a sort of || class loaders could harm :)

      • + 0 comments

        || class loaders will handle it, because they synchronize class loading inside of jvm. Nothing to worry about