>>> "Emuleomo, Olu (PME)" <[EMAIL PROTECTED]> 10/12/99 9:20:18
PM >>>
>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.

Firstly method calls don't need to be synced if the code inside them
is.

Synchronized methods lock the WHOLE method.

In implementation one should lock just the bit of the code that needs
to be locked.

In some methods this may not matter but in others the method may do
much more than simply access class memeber variables (which might be
the reason for a lock).


Secondly if abstract or interface method calls are synced it becomes
impossible to develop non-synced code to implement the abtsract code.

This would be very annoying if you had a thread-safe piece of code to
implement the method.

I think (I'm not sure - but it seems right) that Synchronized
abstract calls would also mean that ALL instances of a class would be
synchronized on the one object. This would be very bad.



Nic Ferrier

___________________________________________________________________________
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