>>> 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....
But synchronized methods aren't the only way to achieve
synchronization and Martin didn't say they were. He just said:
> Not if you synchronize things properly.
For example, here's the drink obsessed method from above:
public void myMeths()
{
synchronized(someLock)
{
this.drink="creosote";
}
}
This will lock only the threads using someLock (whatever that is).
This won't stop many threds form running in other parts of the servlet
class.
So that's how you do it.
Nic
___________________________________________________________________________
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