Yed Su wrote:Thanks Mark and Pete. So as per my understanding, if we talk about singleton scope in a web application bean, each user who access the web app will have their own thread which runs the same single instance of a singleton at same time. Spring container will handle the synchronization issues i. e. as long as the thread is accessing the instance it is locked and the remaining threads will keep waiting for the lock to be released. If this is the case, surely it should be a performance issue.
No.
There is no synchronization being done. There doesn't need to be any, because these beans shouldn't be holding state. So a Controller, Service, Repository/DAO that many user threads are running don't hold state and are therefore threadsafe and don't need to have synchronization blocks.
Mark