错在哪里?急急急急急急急急急急急急急急急急急急急急急急急急急
孙亖 博客专家认证 2004-07-30 11:25:16 public class test {
public static String muteObj = new String();
public static void main(String[] args) {
try {
AnotherThread at = new AnotherThread();
at.start();
System.out.println("before wait..." + Thread.currentThread().getClass().getName());
//statement 1
muteObj.wait();
System.out.println("after wait...");
} catch (Exception e) {
e.printStackTrace();
}
}
}
class AnotherThread implements Runnable {
public void start() {
new Thread(this).start();
}
public void run() {
try {
System.out.println("start another thread...");
Thread.sleep(10000);
System.out.println("end another thread...");
} catch (Exception e) {
} finally {
System.out.println("another thread finally");
test.muteObj.notify();
}
}
}
怎样才能让AnotherThread finally后再执行statement 1.谢了。
急急急急急急急急急急急急急急急急急急急急急急急急急