I got a question in JWebPlus witch states that servlets implementing SingleThreadModel are ThreadSafe. Ok, there is gonna be only one thread at time executing service method, what about Session Attributes, ServletContext Attributes and Classes Variables?
<b><br /><a href="http://mailto:[email protected]" target="_blank" rel="nofollow">Shashank Tanksali</a><br /><i><br />SCJP2,SCJD2,SCWCD<br />IBM Certified Developer - XML and Related Technologies<br />PMI Certified Project Management Professional<br /></i><br /></b>
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
SCJP2
SCJP2, SCWCD, XML, OOAD<br />Kolkata, India
Hence, SingleThreadModel does make you servlet thread safe as it creates a new instance for every request, but its useless as it doesn't serve the purpose for which you might want to make ur servlet thread safe in the first place.
<b><br /><a href="http://mailto:[email protected]" target="_blank" rel="nofollow">Shashank Tanksali</a><br /><i><br />SCJP2,SCJD2,SCWCD<br />IBM Certified Developer - XML and Related Technologies<br />PMI Certified Project Management Professional<br /></i><br /></b>
SCJP2, SCWCD, XML, OOAD<br />Kolkata, India
"Rather the requests are all handled in sequence on the same instance."
This is exactly what happens in a simple servlet which doesn't implement SingleThreadModel.
Hence, SingleThreadModel does make you servlet thread safe as it creates a new instance for every request
<b><br /><a href="http://mailto:[email protected]" target="_blank" rel="nofollow">Shashank Tanksali</a><br /><i><br />SCJP2,SCJD2,SCWCD<br />IBM Certified Developer - XML and Related Technologies<br />PMI Certified Project Management Professional<br /></i><br /></b>
My understanding is that a new instance is not created for every request. Rather the requests are all handled in sequence on the same instance.
SCJP2