Can anyone please pictorially describe what is meant by synchronizing with service method is better than synchronizing on the context attribut itself?? Please help me guys?? I fail to understand as to how wehn we synchronize the service method will still give access to other servlets from the webapp to the context parameters. Please could anyone give a coded example.
Thanks in advance. [ November 11, 2006: Message edited by: Bear Bibeault ]
Synchronizing on the service method would be completely contrary to the whole idea of servlet architecture. Anybody who advises this has not absorbed the basics and you should pay no attention to them.
Thanks for the reply, I'm using the HFSJ and on page number xxv, point number 1 says, "Stop and Think" and to use my Brain(Only 200 grams availabe(lesser than the weight of the book)). I stopped on page 195 where Kim sits and asks to me "What do you think? Will it fix the problem I had??". I'm not able to visualize the system.
My understanding is that, if the service methos is synchronized, then only one request can be handled at a time. Now still when we synchronize on the servletcontext, only one request is going to have access to the servlet context. But what is the point here?? What if all the requests want to access the servletcontext attribute at the same time??? I mean, I don't understand the whole point of it. Please can you throw some light on it?? I would be very much thankful if anyone can get me this straight.