class Coach { // Give the Bunt Signal AFTER setting it!
-
Sign sig = new Sign();
-
...
-
void setBunt() {
-
synchronized (sig) { // Wait for Lock associated with sig
-
sig.bunt = true;
-
}
-
}
-
void giveSign() {
-
synchronized (sig) { // Wait for Lock associated with sig
-
and will not get it until setBunt releases
-
System.out.println("bunt is "+sig.bunt);
-
}
-
} // Continue with coach .....
|