----- Original Message -----
From: Nic Ferrier <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 12, 1999 11:13 PM
Subject: Re: Scrollable resultset/JDBC 2.0
> >Talking about jdbc. (I know its OT, but pls indulge)
> >Anybody know why createStatement() is not SYNCHRONIZED?
>
> This has some VERY on-topic ramifications since Servlets are the most
> common area of the Java platform right now where programmers have to
> deal with synchronization.
I agree totally Nic.
> Firstly method calls don't need to be synced if the code inside them
> is.
>
> Synchronized methods lock the WHOLE method.
>
It can also lock the entire object as well which can have real implications
as far as dead lock is concerned.
If you have done things correctly you should have your connection objects
being taken from and returned to the connection pool that you use (assuming
you are using a connection pool, it is advisable) inside the method that
handles the request. This means that the connection object is only
available to the thread that spawns the request AND that the connection
is only visible to the method being called as well. The threading issues for
connection objects should be dealt with by the connection pool itself
isolating
that problem from the servlet. By doing this you needn't synchronize
methods like createStatement as there should be no threading issues
involved.
If you do have threading problems in this situation then something is wrong.
Hope this helps
Andy Bailey
___________________________________________________________________________
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