how about a class like this:
public class ServletUtil
{
public static final Object objLock = new Object();
.....
}
then u can synchronize on ServletUtil.objLock from your different
servlets
Nguyen Van Hoang wrote:
>
> Tks Richard, but I must have a synchronized func. because each servlet
> must know the "current" value of that field before deciding whether update
> that field or not. So the point is: is that value reached bound value ???
> Maybe when servlet A read that value X, X is under bound value and A
> decide to increase X and do some actions with our virtual machine. But, at
> the same time, servlet B is reading X and also try to increase X and do some
> other actions with our machine. X is not important, but if A and B try to do
> many actions in our machine (at the same time), our machine will die ...
> That's why I need a synchronized function (or object) between 2 (or
> more) servlets to ensure that our simulated machine does not have to receive
> many requests at the same time.
> Tks for reading my mail
> Eric
>
> ---------------------------------------------------------------
> Nguyen Van Hoang
> R&D Engineer
> Arawana Project
> MIS Team
> SSL Viet Nam Ltd.
> ----- Original Message -----
> From: "Richard Yee" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, October 02, 2001 12:22 PM
> Subject: Re: Fw: Synchronized classes ...
>
> > Nguyen,
> > You do not need to synchronize any of the methods in the servlets.
> > If you are only reading the database, there is no need to synchronize any
> > of the methods because the data is not changing.
> > If you are reading and then updating the database, you would want to begin
> > a transaction before you read and update.
> >
> > Regards,
> >
> > Richard
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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