Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Achieving thread safe without synchronize

 
Anand Natraj
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frendz,

Can some one just tell me how to have servlets thread safe without using synchornizing a block in my code.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create new objects (if it is possible) to avoid synchonization.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use instance variables.
Declare all of your variables inside your doGet and doPost methods.
This will take you a long way.

If you have multiple requests accessing context or session scope objects, you may need to do some more thinking. There are no simple rules in these cases.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!