This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Achieving thread safe without synchronize Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Achieving thread safe without synchronize" Watch "Achieving thread safe without synchronize" New topic
Author

Achieving thread safe without synchronize

Anand Natraj
Ranch Hand

Joined: May 17, 2004
Posts: 53
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

Joined: Feb 27, 2002
Posts: 8876

Create new objects (if it is possible) to avoid synchonization.


Groovy
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Achieving thread safe without synchronize
 
Similar Threads
vetor thread safe?
thread safe
what is means by thread save ?
synchronization
threadsafe objects