当前位置: 技术问答>java相关
如何让一个停留的界面,继续向下运行。
来源: 互联网 发布时间:2015-11-02
本文导语: public String SocketActiveHandle(String airs) { 1 netThread = new NetThread(airs); 2 netThread.start(); 3 netThread.stopThread(); 4 System.out.println("test net run!!!49"); 5 return airss; } //线程类 class NetThread extends...
public String SocketActiveHandle(String airs) {
1 netThread = new NetThread(airs);
2 netThread.start();
3 netThread.stopThread();
4 System.out.println("test net run!!!49");
5 return airss;
}
//线程类
class NetThread extends Thread {
private volatile boolean stopThread = false;
private String airs = new String();
NetThread(String airs){
this.airs = airs;
}
void stopThread() {
stopThread = true;
}
void dispDyCanvas(){
Display.getDisplay(AirDest.airdest).setCurrent(dyCanvas);
}
public void run(){
while (!stopThread){
6 dispDyCanvas(); //显示界面
7 airsocket.write(airs);
8 //读出数据
9 receiveNetApp(); //刷新界面
10 airss = airsocket.read();
11 pauseNetApp(); //刷新界面
12 airsocket.close();
13 System.out.println("stop Thread");
}
}
}
运行后,系统打印完
stop Thread,就是13行
就不向下运行了,第四行无法运行,请问如何解决,线程里显示的是界面
1 netThread = new NetThread(airs);
2 netThread.start();
3 netThread.stopThread();
4 System.out.println("test net run!!!49");
5 return airss;
}
//线程类
class NetThread extends Thread {
private volatile boolean stopThread = false;
private String airs = new String();
NetThread(String airs){
this.airs = airs;
}
void stopThread() {
stopThread = true;
}
void dispDyCanvas(){
Display.getDisplay(AirDest.airdest).setCurrent(dyCanvas);
}
public void run(){
while (!stopThread){
6 dispDyCanvas(); //显示界面
7 airsocket.write(airs);
8 //读出数据
9 receiveNetApp(); //刷新界面
10 airss = airsocket.read();
11 pauseNetApp(); //刷新界面
12 airsocket.close();
13 System.out.println("stop Thread");
}
}
}
运行后,系统打印完
stop Thread,就是13行
就不向下运行了,第四行无法运行,请问如何解决,线程里显示的是界面
|
因为你调用了netThread.stopThread();
|
13行后应该显示下一个Screen,要不然就一直停在屏幕dispDyCanvas()中。
不是Thread停止了,而是已经运行完了
不是Thread停止了,而是已经运行完了