am I missing something, but looks like you're trying to build some
kind of web cache. why not use Hibernate or something that already
does caching for you instead?

the only time I can see a need to sync, is if the request contains
data that requires a transaction. Which in that case, you're better
off doing an insert, then a second select query with the same
connection.

or is the scenario a distributed objects setup?

peter


On Thu, 30 Sep 2004 10:05:41 -0400, Malia Noori
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I am using Tomcat 4.1 and I am accessing MS SQL Server database via JDBC.  I
> have a JSP that calls a web bean.  This web bean has a section of code that
> I want to synchronize, but when I synchronize the method, Tomcat doesn't
> actually synchronize the threads.  (I tried this by having 2 users access my
> JSP at the same time).  When I synchronize the code in the method by using a
> mutex, it works.
> 
> So, doing this doesn't work:
> 
> public synchronized void amethod()
> 
> {
> 
>  //some code that access the database and needs to be synchronized
> 
> }
> 
> But doing this works:
> 
> public void amethod()
> 
> {
> 
> String mutex = "";
> 
> synchronize(mutex)
> 
> {
> 
>  //some code that access the database and needs to be synchronized
> 
> }
> 
> }
> 
> Why does synchronization on the method doesn't work?  Does Tomcat not allow
> locking of object caused by method level synchronization?  Any help will be
> appreciated.
> 
> Thanks,
> 
> Malia
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to