L
Luca D.
Let's suppose to have two threads, A and B, which use an object C:
public class C {
public synchronized void f1() {
while(true) {
wait();
}
}
public synchronized void f2() {
notifyAll();
}
}
If A and B have THE SAME reference to the object C, and A calls f1(),
can B call the mothod f2 to wake up A, or the entire object C is
blocked because of the waiting thread (A)?
Would it make any difference if A and B had two different instances of
C?
Thanks.
public class C {
public synchronized void f1() {
while(true) {
wait();
}
}
public synchronized void f2() {
notifyAll();
}
}
If A and B have THE SAME reference to the object C, and A calls f1(),
can B call the mothod f2 to wake up A, or the entire object C is
blocked because of the waiting thread (A)?
Would it make any difference if A and B had two different instances of
C?
Thanks.