我开始一项活动,并在创建时调用此下载方法
public void download(){
thread = new Runnable () {
public void run() {
try{
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/*
* Create a new ContentHandler and apply it to the
* XML-Reader */
WeatherHandler gwh = new GoogleWeatherHandler();
xr.setContentHandler(gwh);
/* Parse the xml-data our URL-call returned. */
temp////is a url defined
xr.parse(new InputSource(temp.openStream()));
ws = gwh.getWeatherSet();
}
catch(Exception e){
}
}new Thread(thread).start();
}
问题是,如果我调试并实际越线thread.start
,它是否有效,如果不是,线程不会启动?我怎样才能从网站上下载信息?