SCEA part I,TOGAF Foundation
There is no emoticon for what I am feeling!
SCEA part I,TOGAF Foundation
Originally posted by Ayub ali khan:
Hi Jeff,
Thank you for your answer. I have one more query, how to make a servlet ThreadSafe?
Thanks and Regards
Ayub.
Kamlesh
Be oN edGE SCJP 1.4, on edGE for SCWCD 1.4
Originally posted by kamlesh tayade:
>>Thank you for your answer. I have one more query, how to make a servlet ThreadSafe?<<
Implimenting the ThreadSafe interface is the one way.It may create difficult to access the resources in the multitaking process so better to go for syncronisation about the specific details which u want to be threadsafe. this way is most prefered one.
SCEA part I,TOGAF Foundation
There is no emoticon for what I am feeling!
am I correct in assuming that I have to sinchronize my methods if I want to avoid multiple threads from accessing it ?
Originally posted by Ayub ali khan:
Hello Jeff,
I had a doubt about single Thread model. Creating a single instance of a servlet. so am I correct in assuming that I have to sinchronize my methods if I want to avoid multiple threads from accessing it ?
Thank you. I appreciate all your answers.
Originally posted by Manhar Puri:
Hence anything in init() and destroy() is not thread safe and you will have to use synchronization to make it thread safe.
Originally posted by Manhar Puri:
Servlet Basics
Servlets have three methods init(), service() and destroy(). Out of these init() is called only when the servlet instance is created. Service() method is a thread safe method which is called everytime a new request is recieved. Destroy() method is called only once when the servlet instance is removed.
Hence anything in init() and destroy() is not thread safe and you will have to use synchronization to make it thread safe.
-Manhar
Yes, if the methods you have created in your servlet access any instance variables the this access needs to be synchronized.
Originally posted by Manhar Puri:
okay a few mistakes in above post.