Hi > I have to synchronize on the method ...
No you do not need to synchonize on the method, you need to synchronize.
You can synchronize on anything.
The easiest would be to do the following:
public static synchronized void amethod()
{
//some code that access the database and needs to be synchronized
}
Just make your method static.
Synchonization will not occur on the instance object any more, but on the
Class object of your instance.
Since tomcat may instantiate multiple servlets, it may only do so in the
same classloader. Therefor all instances belong to the same Class object and
will synchronize as you required.
Regards,
Steffen
smime.p7s
Description: S/MIME cryptographic signature
