aspose file tools*
The moose likes Servlets and the fly likes Synchronization? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Synchronization?" Watch "Synchronization?" New topic
Author

Synchronization?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9521
    
    2

Hi Ranchers,

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 ]

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
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.

Where did you see this suggestion?

Bill
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9521
    
    2

Hi William,

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.

Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronization?