> 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?