They say that early binding solves the problem of synchronization. I couldn't understand "how". Is this something special to Java or the same applies to C++ too?
so, with this method we actually won't require a mutex lock?
The JVM ensures that each class is fully loaded before allowing any access to it via other threads. This means that all static variables, including uniqueInstance
above, at fully instantiated before they can be accessed. This is specific to Java and means you don't need synchronization to protect the publication of the instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With