当前位置: 代码迷 >> J2SE >> 继承Runnable无run方法,怎么跑法
  详细解决方案

继承Runnable无run方法,怎么跑法

热度:7549   发布时间:2013-02-25 00:00:00.0
继承Runnable无run方法,如何跑法?
[code=Java][/code]SimpleFlow s = null;
s = new CreditPrintFlow();
if (s != null) {
Thread t = new Thread(s);
t.start();
return "SUCCESS";
} else
return "FALSE";
[code=Java][/code]public abstract class SimpleFlow implements Runnable {

IObserver ob = PageObserver.getInstance();

JobResource jr = JobResource.getInstance();

public IObserver getOb() {
return ob;
}

public JobResource getJr() {
return jr;
}

static HashMap<String, JobNode> nodeMap = new HashMap<String, JobNode>();

public abstract HashMap<String, JobNode> getNodeMap();

public SimpleFlow(String batchFiler, String brnoFilter, String preFlag, String priFlag, String operator) {
jr.setBatchFiler(batchFiler);
jr.setBrnoFilter(brnoFilter);
jr.setPreFlag(preFlag);
jr.setPriFlag(priFlag);
jr.setOperator(operator);
}

public void startup() {
JobDispatch.runFlow(this);
}
}
启动线程后正常会调用SimpleFlow 复写的run()方法,但是SimpleFlow 只有基本的构造函数,请问该线程启动后会如何调用?

------解决方案--------------------------------------------------------
s = new CreditPrintFlow();

Thread t = new Thread(s);

这里s是一个CreditPrintFlow的实例。Thread.start()是调用的CreditPrintFlow的run方法。
如果SimpleFlow 是CreditPrintFlow的父类。那,SimpleFlow 没有run方法,CreditPrintFlow就要有了
  相关解决方案