按照jdk的说明没有notify()或notifyAll(),wait()不会醒过来的,关注一下~~知道的说明一下哦
解决方案 »
- 怎样改变JScrollPane滚动条的颜色及样式?
- 遇到连接orcale的问题,请高手指点小菜鸟!!!!不胜感激
- JTabbedPane tab上的小X用来关闭 怎么实现
- 我编译老说找不到javax.servlet.*
- 程序怎么写 请教大家
- 请各位指证错误,同时阐述道理.谢谢!!
- 面向对象入门求助~~~感觉java的"继承"功能设计得很混乱?
- 请问JAVA中的MVC(model-view-controller)与mfc中的Document-View是否是一个概念?
- 关于数据库联接代码调试事的错误判断?
- 高分求救!!!(200)我回多问相同问题来给分的,急急急
- 一技防身
- 两个JList如何传递元素.
private class T extends Thread {
public void run() {
try {
System.out.println("before!");
this.wait();
System.out.println("after!"); } catch (Exception e) {System.out.println("exception!"); e.printStackTrace(System.out);} System.out.println("morning!"); }
}
public Test_thread(){
T t =new T();
t.start();
} public static void main(String[] args) {
Test_thread t1 = new Test_thread();
try
{
Thread.sleep(2000);
}
catch(Exception ex) {}
}}
也就是的在sychronized里面。
public class Test_thread {
private class T extends Thread {
public synchronized void run() {
try { this.wait(); } catch (Exception e) { }
System.out.println("morning!");
}
}
public Test_thread(){
T t=new T();
t.start();
} public static void main(String[] args) {
Test_thread t1 = new Test_thread();
}}