Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Safety question

 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An implementation of servlet classes.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic