Well, I think I have to put static keyword to specify my method. If not,
different instances will be created and synchronize won't protect all the
instances. Am I understand it correct?

Thanks.

Tiana

____________________Reply Separator____________________
Subject:    Re: Synchronize method in the servlet
Author: <[EMAIL PROTECTED]>
Date:       10/5/00 8:06 AM

It's my understanding that the synchronize keyword does exactly as the name
implies... it synchronizes usage of that method, so that other threads
wishing to use the method have to wait until the thread currently using it
is finished.

----- Original Message -----
From: "Tiana Zhang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 05, 2000 7:47 AM
Subject: Synchronize method in the servlet


> Hello,
>
> The synchronized method I created in the servlet is going to increment a
number
> in the database and display it in the browser. Because I don't want
multiple
> user update the database at same time, I added synchronized keyword in the
> method.
>
> My question is: does synchronize guarantee that only one thread does the
update
> database? Why after many times of testing multiple browsers, I still got
same
> number on different threads which means access to the synchronized method
is not
> exclusive?
>
> many thanks in advance.
>
> Tiana
>
>
___________________________________________________________________________
> 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

___________________________________________________________________________
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