File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Thread Safety question 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 "Thread Safety question" Watch "Thread Safety question" New topic
Author

Thread Safety question

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
What mechanism determines a servlet's thread safety? Is it the container or the implementation of the servlet class?

Thanks again!
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 471
An implementation of servlet classes.


Get power of your iPod with MediaChest | Minimal J2EE container is here | Light weight full J2EE stack | My blog | Co-author of "Windows programming in Turbo Pascal"
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you're not sure how to create a thread safe servlet, follow this basic rule of thumb:
Don't create instance variables.

You could still run into concurrency issues if your servlets or JSPs try to access a session or context scope object at the same time but instance variables are the leading cause of threading problems in servlet applications.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Thread Safety question
 
Similar Threads
criteria search concurrency
authentication problem
multiple threads for database
diffrence b/w calling of getRequestDispatcher form request and getServletCotext.
Concurrency for MDB's