关天重复调用线程的问题:
class thread extends Thread{
@Override
public void run() {
//取数据
try {
city=getIntent().getStringExtra("CityName");
if(city==null){
city="珠海";
}else{
int index=city.indexOf("(");
city=city.substring(0, index-1);
}
//SoapObject来存储返回的数据
detail=gws.getWeather(city);
}
catch (Exception e) {
e.printStackTrace();
}finally{
Message msg = new Message();
msg.what = 1;
mHandler.sendMessage(msg);
}
}
}
启动线程.只需要
thread th;
th=new thread();
th.start();
而当需要再调用回这个纯种方法时,也是只需要
th=new thread();
th.start();
这样是不会产生线程has started 的异常的..因为在Handler里再start线程时..前一个线程已经被QT回收了..这样就可以new 这个线程方法.启动了!!!