• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic