Try this code.. You will see that the synchronized
methods can be entered concurrently because they
are using different locks.
<PRE>
class Funky implements Runnable {
public static void main(
String[] args) {
Thread ravel = new Thread(new Funky());
ravel.start();
method1();
}
public synchronized void run() {
System.out.println("entered nonstatic synchronized method");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
System.out.println("exited nonstatic synchronized method");
}
public static synchronized void method1() {
System.out.println("entered static synchronized method");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
System.out.println("exited static synchronized method");
}
}
</PRE>
Geoffrey
------------------
Sun Certified Programmer for the Java 2 Platform