G
Gyro
Hello, I need to block current thread, waiting for flag/event. Plz give advice.
My attempts:
public synchronized void blockingFormCreate() {
createAndShowForm(); // Create and show screen form
wait(); // Fall asleep
. . .
}
public synchronized void setEvent() {
notify(); // wakeup, continue processing
}
volatile boolean event; // field
private void blockingFormCreate() {
event = false;
createAndShowForm(); // Make a form
for(; !flag; yield()) ; // Blocking
. . .
}
where I`m correct/incorrect ?
My attempts:
public synchronized void blockingFormCreate() {
createAndShowForm(); // Create and show screen form
wait(); // Fall asleep
. . .
}
public synchronized void setEvent() {
notify(); // wakeup, continue processing
}
volatile boolean event; // field
private void blockingFormCreate() {
event = false;
createAndShowForm(); // Make a form
for(; !flag; yield()) ; // Blocking
. . .
}
where I`m correct/incorrect ?