public class Bees {
public static void main(String[] args) {
try {
new Bees().go();
} catch (Exception e) {
System.out.println("thrown to main" + e);
}
}
synchronized void go() throws InterruptedException {
Thread t1 = new Thread();
t1.start();
System.out.print("1 ");
t1.wait(5000);
System.out.print("2 ");
}
}
出力は次のとおりです。例外()メソッド
1 thrown to main
このthrown to main
がここに来た理由を私は得ていないのです。
かもしれあなたはこれをチェックしている必要があります。http://stackoverflow.com/questions/1537116/illegalmonitorstateexception-on-wait-call – soorapadman
あなたは '待機()'メソッドが何をするのか理解していますか? – Kayaman
@Kayaman wait()メソッドについて考えてください。 –