多线程问题,20分 源程序不全,不是很快能看懂!你将ref[i].destroy();前加上 set ref[i] = NULL 看看! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先加上if(ref[i] instanceof Thread) ...调试一下看看,呵呵~~ 源程序已经很全了,这个类里面就一个run方法。set ref[i] = null 不是java格式。设成空自然可以释放内存(ref[i]设成空还怎么invoke那个destroy()方法?!),但是我需要destroy这个线程,我想弄明白的是这个destroy()方法究竟出了什么问题。 不好意思,xhh(霹雳游侠),加上你那段话也没用。以下放上执行方法: public synchronized void set(){ while(lock == true){ try{ wait(1000); } catch(InterruptedException ie){ ie.printStackTrace(); } } lock = true; while(count.length() <50){ System.out.println("Now In Thread "+ this.getName() + " COUNT's length +1."); count +="1"; System.out.println("Now COUNT value is: "+ count); lock = false; try{ wait(1000); } catch(InterruptedException ie){ ie.printStackTrace(); } notifyAll(); } } public void run(){ try{ System.out.println("Now Thread "+ getName() + " is running"); this.sleep(1000); set(); System.out.println("Now Thread "+ getName() + " is end."); } catch(InterruptedException ie){ ie.printStackTrace(); } }其中涉及的域: private static String count = ""; private static boolean lock = false; 关于文件读写的小问题 看看这个异常是怎么回事:ResultSet is closed 搞不大清“JVM抛出的异常”“以编程方式抛出的异常”有什么不同。 (求助)大家帮忙看下我这段小程序 Runtime 问两个简单问题 谁能帮我解决UDP编程中的问题! 这段代码,编译通过,运行时出错,大家给个答案吧 java连接数据库时怎样用ADO,就是不用在odbc中建立数据源而直接连接数据库? 有关一些网络游戏他的服务器数据是怎么发送的,难道是服务器定时向客户发送? 请问:如何获得jTextField 的鼠标双击事件 好就是这个问题 如何才能把图标加到浏工具条上去?
if(ref[i] instanceof Thread)
...
调试一下看看,呵呵~~
set ref[i] = null 不是java格式。
设成空自然可以释放内存(ref[i]设成空还怎么invoke那个destroy()方法?!),但是我需要destroy这个线程,我想弄明白的是这个destroy()方法究竟出了什么问题。
以下放上执行方法:
public synchronized void set(){
while(lock == true){
try{
wait(1000);
}
catch(InterruptedException ie){
ie.printStackTrace();
}
}
lock = true;
while(count.length() <50){
System.out.println("Now In Thread "+ this.getName() + " COUNT's length +1.");
count +="1";
System.out.println("Now COUNT value is: "+ count);
lock = false;
try{
wait(1000);
}
catch(InterruptedException ie){
ie.printStackTrace();
}
notifyAll();
}
}
public void run(){
try{
System.out.println("Now Thread "+ getName() + " is running");
this.sleep(1000);
set();
System.out.println("Now Thread "+ getName() + " is end.");
}
catch(InterruptedException ie){
ie.printStackTrace();
}
}
其中涉及的域:
private static String count = "";
private static boolean lock = false;