I have discussed this problem with people but they all seem quite confused about it. Can any one help me?
// position a
synchronized void A() { <-- method
// position b
B();
}
synchronized void B() { <-- method
// position c
C();
}
synchronized void C() { } <-- method
synchronized void D() { <-- method
C();
}
There are two threads running naming 1 and 2.
Thread 2 called method D, locked method C and did not exit. What will happen when thread 1 calls method A now?? Will it suspend before calling method A (position a), immediate after calling method A (position b) or after entering method B (position c) ??
Please help. Thanks in advance.
// position a
synchronized void A() { <-- method
// position b
B();
}
synchronized void B() { <-- method
// position c
C();
}
synchronized void C() { } <-- method
synchronized void D() { <-- method
C();
}
There are two threads running naming 1 and 2.
Thread 2 called method D, locked method C and did not exit. What will happen when thread 1 calls method A now?? Will it suspend before calling method A (position a), immediate after calling method A (position b) or after entering method B (position c) ??
Please help. Thanks in advance.