Lets say we have a server running on a machine, say a CPU.
Now on that server, lets say my application is running. I know that my container will handle multiple clients.I mean using multiple threads for every request. But afterall , CPU can run only one thread at a particular time ..right? so wont other threads wait and wont the users see delay?
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
You can ask yourself the very same question: how can you load a page and listen a music in the same time? Or how can you play games (video, music, key strokes actions, mouse position recognition)?
How does the CPU let you do few things in the same time and still you can't see the delay?
And what about people in only-single-CPU times? How did they work... :-)
Simplifying the whole thing - the CPU is basically using a round-robin scheduling which gives each thread a slice of time to act, then the thread is moving out (CPU changes the context) and another thread goes in action. Then it's moved out, another goes on and so on.
This question is not related to the Servlet, EJB or any other container but rather to OS/CPU scheduling basics.
Oh and I did forgot to add that the round-robin uses slices so small that user basically can't tell the difference and, in the same time, it gives a feeling that multiple threads can run in the same time. So it's basically "cheating" the user to make an impression that it all happens in the same moment.