• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronization in servlets

 
ch praveen
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
Basically My servlet is not based on SingleThreadModel, but I want to synchronize only a particular portion of it [reading and writing data to a ServletContext Attribue]. Please post your suggestions.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Synchronization in servlets is the same as synchronization in any other Java environment. However, I don't think that simple adding or removing and object as a ServletContext attribute would require synchronization. Of course if multiple requests could modify the object, thats another story.
Browsing around in the source for the Tomcat implementation of ServletContext, I found:

so it looks like the implementation is already taking care of synchronization.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic