Hello friends,
lets see if that helps.
1) Servlet container generally keeps a single instance of a servlet on memory, but its not a binding by specification.
For optimization purpose, it may create another instance, and do the processsing.
2) Implementing SingleThreadModel is one way to keep only a single worker thread executing a method on servlet instance, but if container decides to create another instance , then still many intances may work in tandom and may be called upon my worker threads (one at a time). So , single thread model doesnt mandate only a single instance.
SingleThreadModel doesnt mean single thread model of a servlet instance...its not a thread. It means single thread model of worker threads....if its singlethread model, a single worker thread will model on an instance.
3) On this I agree with Prakash. A synchronized method will ensure that a single thread works on the method. But if more instances are there, those many mehtods can be served at a time. Even I had this doubt in mind when I was studing, but while execution I didnt found any different situation,
please elaborate on this if possible.
When a method is synchronized, does it have only one existance(as static method) eventhough many instances are there? If yes then book is right, but if not then it can be simult. executed.
Thanks
amol
scjp