By spring docs I found by default spring beans are singletons. How will spring behave if it has a doSomethingMethod() { … } and this method is being called by multiple clients at same time, will they share the same values being used in the function?
Share
It just depends on the bean itself. There is no requirement that the bean be threadsafe, stateless, etc. If the bean isn’t threadsafe, then sure, data races can result.
See also:
what happens if more than one thread tries to access singleton object
Not an exact duplicate since we’re talking about slightly different senses of singleton here, but the same ideas apply.