Nic Ferrier wrote:
>
> >>> Access Denied <[EMAIL PROTECTED]> 22-Mar-01 3:31:32 AM >>>
> >You can't used synchronized methods in servlets, can you?
>
> Of course you can.
>
> It's not terribly advisable though because a synchronized method,
> eg:
>
> public void synchronized myMeths()
> {
> this.drink="whiteSpirit";
> }
>
> synchs all the threads on the servlet object. This means that only
> one thread will be able to operate on the servlet at once. Kinda
> defeats the point of servlets that....
Synchronizing the method myMeths() does not prevent other threads from
entering or running in other parts of the servlet (unless service(), or
doPost() and doGet() are also synchronized methods). Using the lock of
the servlet object will only stop threads from entering blocks or
methods that are also locked on the servlet object. If only myMeths() is
synchronized, then other threads will be able to enter the servlet, and
will be able to run, as long as they do not enter the myMeths() method.
___________________________________________________________________________
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