why this simple java application do infinete while loop?
why this simple java application do infinete while loop?
thanks very much
niv jokop
Code:
class DualSync {
public boolean busy=true;
public synchronized void store() {
System.out.println("before");
while (busy) ;
System.out.println("after");
}
public synchronized void read() {
}
}
public class SyncObj{
public static void main(String[] args) throws InterruptedException {
final DualSync ds = new DualSync();
new Thread() {
public void run() {
ds.store();
}
}.start();
Thread.sleep(5000);
ds.busy=false;
ds.read();
System.out.println("end main");
}
} ///:~
1 Attachment(s)
here is a screenshot of my eclipse notice the red square
here is a screenshot of my eclipse
notice the red square that signals the application is still running.
notice also that the console output is only "before"
thanks for your interest
niv jokop