• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Thread-Safe

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic