//实现方法pubRmRecordByRmPlanId @Override public OperateResult pubRmRecordByRmPlanId(Long rmPlanId,String taskBeginDate,UserInfo userInfo) { ... final String planId = String.valueOf(rmPlanId); final String taskBeginTime = taskBeginDate; //新开一个线程统计分析报告 new Thread(new Runnable() { @Override public void run() { exceptionAnalysisService.runAnalysisStrategyJob(planId, taskBeginTime); //参数必须是final类型的 } }).start(); ... } }
import java.util.concurrent.TimeUnit; private void change() { Thread t1 = new Thread(new Runnable() { public void run() { int i=0; while (true) { try { i++; // 后面为具体操作 XXX Thread.sleep(500); } catch (InterruptedException e) { } } } }); t1.setDaemon(true); t1.start(); }