What happens if a thread executing a synchronized
method suspends? Will other Threads get the lock and proceed with another synchronized
method in the same class..?
Suppose the code is like:
class Test{
public synchronized void methodA(){
//methodA
}
public synchronized void methodB(){
//methodB
}
}
If ThreadA
execute methodA()
. And while executing the method if it get suspended implicitly by the OS. Will another Thread, say ThreadB
can get the lock and execute methodB()
? or is it possible only after the ThreadA
completes its work with methodA()
?