In running your code the problem seems to be that the "Waiting shape..."
message is never reached. This surprises me but it seems like the while (true) { synchronized(c)
is never letting the Maquina
into the synchronized
block.
Adding a small sleep at the front of the Operator.run()
method fixes the problem. It gives time for the Maquina
to get the lock and enter wait()
.
while (true) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
synchronized (this) {
System.out.print("Altura: ");
altura = in.nextInt();
System.out.print("Largura: ");
largura = in.nextInt();
notify();
}
}