I agree with one exception. If you are using prepared statements you should
synchronize that section of your code.




Bill Hackmann <[EMAIL PROTECTED]>@JAVA.SUN.COM> on 10/05/2000 06:28:20 PM

Please respond to "A mailing list for discussion about Sun Microsystem's Java
      Servlet API Technology." <[EMAIL PROTECTED]>

Sent by:  "A mailing list for discussion about Sun Microsystem's Java Servlet
      API Technology." <[EMAIL PROTECTED]>


To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Synchronize method in the servlet


The synchronized should be unnecessary; The database locks should do all
serialization necessary.  Consider how you would have to do this if your
server was split over several systems.

At 08:47 AM 10/5/00 -0500, you wrote:
>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