The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Synchronized method in threading environment

Posted by Matt Gerrans on February 22, 2002 at 1:08 PM


> I've programmed a servlet to call a threading class. However, I found that the synchronized method in threading class are not locked. Another thread can call this synchronized method even the first thread are not finished.
> My question is: Can synchronized method works normally in threading environment with servlet program?

Could you post the code? What evidence do you have have the method isn't locked? (You could print "starting" method at the start and "finished" at the end; do you get two "starting"s in a row?) Is everything running in the same JVM? That is, is the "other" thread that is calling the method also in a servlet being serviced by the same container?





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us