私は遊ぶためにこのばかげたプログラムを作成しましたwait()
public class WaitTest {
public static void main(String [] args) {
System.out.print("1 ");
synchronized(args){
System.out.print("2 ");
try {
args.wait();
args.notifyAll();
}
catch(InterruptedException e){ System.out.print("exception caught");}
System.out.print("3 ");
}
}
}
私のマシンでは、wait(100)
別のミリ秒数を書き込まない限り、コードは 3 を出力しません。どうしてこれなの?