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

which variables Thread safe in servlets ?

 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have read that only local varibales anb request is thread safe at HFSJ.

At some mock exams , It said that response object and immtable objects ( which are declared as final).

Is it correct ?
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think, knowing about how different threads access the servlet code?
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes !! acessing different threads the same servlet code.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply remember these lines for your Life -->

1: If your servlet is Implementing the SingleThreadModel interface..
then Request,Response,Local variables and Instance variables are Threadsafe.

2: If your servlet is NOT Implementing the SingleThreadModel interface..
then Request,Response and Local variables are Threadsafe.

 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use the SingleThreadModel interface it's depreciated.

Servlet Best Practices
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic