Suppose I have two threads, T1 and T2. I would like to ensure that if T1 is calling method A1()
, then T2 cannot call method B1()
. Similarly, if T1 is calling method A2()
, then T2 should not be able to call method B2()
.
How might I achieve this?
class A {
public void A1() {
}
public void A2() {
}
}
class B {
public void B1() {
}
public void B2() {
}
}