This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronized in servlets  RSS feed

 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I came across an example of a ShoppingCart that synchronized its addItem and setNumberOrdered methods. I can understand that they need to be locked up while being mutated so the data won't be corrupted by interference from another thread. And this ShoppingCart is put in a HttpSession object. However, in the servlet that does the ordering, it was the session object that is in a synchronized block. So, I think I am confused is do these mutator methods need to be synchronized when the session object is "held" in the synchronized block?
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!