I got these asked in an interview.
Do we need to take care of clone method in a concurrent environment ? Can we synchronize the clone method ?
Does it make any sense to use clone method in singleton classes ?
I did not have convincing answers for this during the interview.
Probably yes 99.99% of the times but you just have to think at clone like any other methods of your class and synchronize it if necessary depending on your specific context. There is nothing wrong in synchronizing a method that is not synchronized in its Base class. On the other hand, not synchronizing a method while overriding a synchronized one is probably a mistake even if the code compiles fine and no warnings are issued...
A convincing answer would probably be NO with a couple of words on the singleton design pattern.
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