Marc Krisjanous <[EMAIL PROTECTED]> 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
>
no, since the servlet engine may make multiple instances of your
sevlet (most will), and Java syncronizes on an object. In any case , my personal view
is that it is better to protect the object you care about, so in this case it would be
the FileOutputStream.
Tim.
so syncronize on the---
URL http://www.westhawk.co.uk/
___________________________________________________________________________
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