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-Safe

 
iyven koh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all SCWCD ranchers,
I have quuestions on whether HttpServletRequest and HttServletResponse object are thread-safe? according to exam study-kit, the req and res object are thread safe but from the book of ExamCram2 is saying that they are not thread safe. I am confused..
another doubt is on instance variable, from the exam study-kit, instance variabe is thread safe if the servlet implements SingleThreadModel and not thread safe if it is multithreaded servlet. however, ExamCram2 saying that it is not thread safe no mater is single or multi threaded model???
Hope somebody out there could give me an answer, thanks for help!
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by iyven koh:
Hi all SCWCD ranchers,
I have quuestions on whether HttpServletRequest and HttServletResponse object are thread-safe? according to exam study-kit, the req and res object are thread safe but from the book of ExamCram2 is saying that they are not thread safe. I am confused..

I was pretty sure they were thread safe

another doubt is on instance variable, from the exam study-kit, instance variabe is thread safe if the servlet implements SingleThreadModel and not thread safe if it is multithreaded servlet. however, ExamCram2 saying that it is not thread safe no mater is single or multi threaded model???
Hope somebody out there could give me an answer, thanks for help!

well, what's the argument they give in ExamCram2? I read the study kit and their explanation is convincing.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request and response are thread-safe because request ans response are parameters of service method
eg.
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
//request and response is local variable of this method which are thread-safe
}
instance variable is not thread-safe but its thread-safe when servlet implement javax.servlet.SingleThreadModel interface
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic