java 线程异步调用

1、继承implements Runnable
如: public class PurchaseSerialNewController extends BaseMultiActionController implements Runnable

2、实现run 方法
/**
* 创建一个线程,用于框架协议的启用、禁用
*/
public void run() {
// System.out.println("================="+id);
DataSet ds=DataBase.Query("select contract_id from contracts where status='2' and purchase_serial_id="+this.purchaseSerialId);
if(ds.RowCount>0){
//启用/禁用框架协议
this.clientService.downReviewPurchase(this.purchaseSerialId, true, null);
//合同系统启用/禁用框架协议
this.clientService.downReviewPurchase4Compact(this.purchaseSerialId, true, null);
}
}


3、调用start()方法

//开启线程异步调用 启用/禁用框架协议
PurchaseSerialNewController ps=new PurchaseSerialNewController();
ps.setPurchaseSerialId(id);
//由于是新创建的ps对象,要将里面的属性传递给run方法
ps.setClientService(this.clientService);
Thread t=new Thread(ps);
t.start();
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页