B
byhesed
public class A {
synchronized void m1() { ... }
synchronized void m2() { ... }
void m3() { ... }
}
The book explains above code:
Given an instance a of class A, when one thread is executing
a.m1(),
another thread will be prohibited from executing a.m1() or a.m2().
I have a question.
The explanation means than when one thread is executing m1() method,
No other threads can execute m1() or m2() thread.
Is it correct? If it is correct, how can I handle it better?
I think it is too ineffectual. Does anybody know?
synchronized void m1() { ... }
synchronized void m2() { ... }
void m3() { ... }
}
The book explains above code:
Given an instance a of class A, when one thread is executing
a.m1(),
another thread will be prohibited from executing a.m1() or a.m2().
I have a question.
The explanation means than when one thread is executing m1() method,
No other threads can execute m1() or m2() thread.
Is it correct? If it is correct, how can I handle it better?
I think it is too ineffectual. Does anybody know?