synchronize on static method will lower performance significantly.  Instead,
you can synchronize a block inside the method.

-----Original Message-----
From: Tiana Zhang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 05, 2000 11:45 AM
To: [EMAIL PROTECTED]
Subject: Re: Synchronize method in the servlet


The reason I think I have to put static keyword for the method is because my
method is going to update the database by JDBC connection. I don't want
multiple
thread updating the database at the same time.

Here is my code:

public static synchronized String assignNum(String name, String uID, String
requestType, String comment){

    String rID = "";
    try{
        rID = db.DBinsert(name, uID, requestType, comment);
        db.updateSeqNum(requestType);

    } catch (Exception e) {
        System.err.println(e.toString());
    }
    return rID;
}

Thanks for the replys.

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

Reply via email to