今天遇到了很奇怪的runnable写法,之前Thread的两种基础写法就不多说了。记一下今天遇到的写法:
public class httpThread2 implements Runnable {
private static httpThread2 sc;
private Handler handler;
public static synchronized httpThread2 getInstance(String msgid,String url,Handler handler) {
if (sc!=null) {
sc=null;
}
sc = new httpThread2();
sc.msgid = msgid;
sc.WSDL_URL=url;
sc.handler=handler;
sc.run();
return sc;
}
public httpThread2(){
}
@Override
public void run() {
<span style="white-space:pre"> </span>........处理函数
}
}
线程如下:
private httpThread2 mTcpServer;
private void Soap_xml(final String xml) {
if (mTcpServer != null) {
mTcpServer = null;
}
Thread thread = new Thread(new R