Hi,
According to the servlet 2.2 spec section 3.3.3.1 on Multithreading issues:
"During the course of servicing requests from clients, a servlet container
may send multiple requests from multiple clients through the service method
of the servlet at any one time. This means that the Developer must take care
to make sure that the servlet is properly programmed for concurrency"
It means that the servlet will be multithreaded, but you will have to take
care of concurrency.
Further the spec says that "...........It is strongly recommended that
developers not synchronize the service method or any of the HttpServlet
service methods such as doGet, doPost, etc."
You can synchronize your servlet methods, but the whole app becomes slow,
since the calls have to be queued. Better to use the SingleThreadModel
instead.
Hope this helps,
Anil.
----------------------------------------------
Anil Colin Lobo
Senior Software Engineer
Aztec Software and Technology Services (P) Ltd.
Web: http://www.aztec.soft.net
Office Address:
Aztec Software and Technology Services (P) Ltd
23, 3rd A Cross, 18th Main, 6th Block, Koramangala, Bangalore - 560095
Phone: 091-080-5522892 extn 156
-----Original Message-----
From: veena T [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 24, 2000 3:00 AM
To: [EMAIL PROTECTED]
Subject: Re: synchronized methods - simple question
>Is this true??
I donot think that is necessary. Please check it again.
Bye,
veena T
---
Veena T
Assistant Profesor,
Manipal Center for Information Science,
Manipal.
576 119
Email: [EMAIL PROTECTED]
Telephone: 91+08252-71915/71914
On Sun, 21 May 2000 17:10:32 Marc Krisjanous wrote:
>Hi all,
>I wonder if anyone can confirm the following:
>
>I have a servlet that will call a synchronized method that will write to a
>file. My understanding of how Servlets work is that for every web session
>(web browser) which calls the servlet the servlet will have a thread
created
>for that session in which data will be stored for that session but each
>thread will use the same method(e.g the class and methods will not be
>created for each thread). Thus in order to access and write to external
>media you need to make that method synchronized since in theory there is
>only one method that all threads share.
>
>Is this true??
>
>Best Regards
>
>Marc
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html