多线程问题,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; 实在想不出来 一个代码问题,请解释!谢谢! 我想找个JAVA的工作(北京),各位兄弟帮帮我啊,如果你们的公司缺人的话介绍我进去,我给你5000分!! 关于按钮事件 请教日期问题 据××说JAVA比C++甚至C快 jbuilder8 中运行时总弹出project properties窗口??? 使用applet(Jcreator)怎么能够产生文件打开和保存对话框? 想让Applet访问本地硬盘,用数字签名,请问具体步骤怎么实现??急!急! 实时获取进度 好就是这个问题 如何才能把图标加到浏工具条上去?
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;