Max Samukha wrote:
Lazy initialization requires some kind of synchronization when a is shared. Static initialization does not have that drawback.

That's correct (otherwise you have the double checked locking bug).

Wrapping the function body in a synchronized statement will do the trick.

(Yes, it's slower.)

Reply via email to