We know that Servlet loads in to memory only once when first request comes for it and for all subsequent request, new threads create by container.
We also know that synchronized constructor is not possible.
Now my question is:
Assume simultaneously 100 requests come for same Servlet (assume requests come at same time from all client to server).
On first request, container will create object of class and then thread. So if 100 request comes simultaneosly, How it will synchronized object creation?
So how container handle this situation?
How container first load Servlet into memory and at that time prevent remaining 99 request to wait?
I am guessing here, but the container is probably synchronizing inside the Factory method.
This question is not really a "servlet" question. The core of the question is "In a concurrent environment, how is a lazy loaded singleton guaranteed to be a singleton?" You might want to look into Singleton pattern, and Factory Pattern. This page has a list of references that you can go through.