Suppose that there are several instances of a class that simultaneously call service methods defined in a singleton class.
Can someone explain to me what happens at a low level when a method is called in singleton mode, when this method is already being executed by some other instance of the class? I think the JVM blocks the caller until the current caller is executed using the method. Is it correct?
Will performance improve if we move some of the methods in a singleton class to define them in a class that needs such methods?
Will performance be improved if singleton is changed to non-singleton, allowing each instance of the class that requires calling service methods in another class to create its own instance of the service class?
Suppose singleton is stateless.
Consider the situation of multiple threads calling singleton service methods.
source
share