hey all,
I have the run method in a class which is synchronized. Inside the method run() i have called a different method which is unsynchronized. Here is the program:
---------------------------------------------------------------------------
public class SynchClass {
public static void main(
String[] args) {
ImpRunnable imRun = new ImpRunnable();
Thread tr1 = new Thread(imRun);
Thread tr2 = new Thread(imRun);
Thread tr3 = new Thread(imRun);
tr1.start();
tr2.start();
tr3.start();
}
}
class ImpRunnable implements Runnable {
public synchronized void run() {
try {
Thread.sleep(1000);
} catch(InterruptedException ie) {
}
for(int i = 0; i < 100; i++) {
callMe();
System.out.println(i + "time" + Thread.currentThread().getName());
}
}
void callMe() {
System.out.println("hii");
}
}
------------------------------------------------------------------------
My doubt is that whether the thread currently having the lock will still be holding the lock during the execution of the method callMe(), which is unsynchronized? and why?