要实现Thread的暂停,现在有什么方法代替Thread.stop() 那stop什么方法啊,是终止吗?但现在不能用啊,怎么实现进程的终止呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用一个布尔标志做检测,其他线程通过置当前线程运行标志为否,使其退出Thread 1:private volatile boolean running=false;...running=true; //可在构造中置为Truepublic void setRunning(boolean flag){ this.running=flag;}public void run(){while(running){ .....}}Thread 2:thread1.setRunning(false); //使Thread1 的run方法退出,即线程中止。 RamdonAccessFile乱码问题 什么是面向接口编程 菜鸟提问 求带有农历的日历代码 求助一界面布局问题!! 急求大神解决:关于java IO包 读和写的问题..... 麻烦您给讲解一下Timer的用法和注意事项 高手都来,回答后重谢超过想像 急:JAVA中求最大质数的算法(要求速度最快啊) hashmap里面的值取不出来 这样的SQL的语句为何在JAVA Applet中不能运行 编写程序求出c:\下有多少个文件夹? 请问如何在jComboBox控件下拉列表中如何加入图片并同时加入说明文字啊?
Thread 1:private volatile boolean running=false;
...running=true; //可在构造中置为True
public void setRunning(boolean flag){
this.running=flag;
}
public void run(){
while(running){
.....
}
}Thread 2:
thread1.setRunning(false); //使Thread1 的run方法退出,即线程中止。