How about a third class "DataAccess"  that implements the single threaded
model, and ONLY use that class for getting the data with a "getData()"
method.  It seems to me that then the second servlet is always blocked until
the first servlet has accurate info.  Depending on how the update occurs,
you might need to route all the changes with a "setData(data)" method as
well.

Just a suggestion...

Mike Brubaker
Orlando Florida
java Developer Wannabe
[EMAIL PROTECTED]


----- Original Message -----
From: "Nguyen Van Hoang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 02, 2001 2:27 AM
Subject: Re: Fw: Synchronized classes ...


>     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

Reply via email to