能不能看你代码咋写的?
是否没有对两个线程分别做初始化?
1:同时停止是因为 由一个变量stop引起
2: Runnable不能start,需要实现new Thread(Runnable).start(); 代码里,oncreate虽然有做
Thread thread1 = new Thread();,但实际并没有引用,逻辑有点混乱 ps:如果 STOP=true 线程满足条件,空闲下来 会被释放
原代码:
if (arg0 == mButton1) {
STOP = false;
thread1.start();
} else if (arg0 == sButton1) {
STOP = true;
}
修改后:
if (arg0 == mButton1) {
STOP = false;
thread1=new mThread();
new Thread(thread1).start()
} else if (arg0 == sButton1) {
STOP = true;
}