自定义FutureTask
long beginTimeFq = System.currentTimeMillis(); //======================================================= Callable<BaseResultMessage> rmFqCallable= ()->{ BaseResultMessage rmFq = Utils.renderBaseResultMessageError(""); try { rmFq = customerService.updateCustomerDataFq(customerBean); }catch(Exception e) { logger.error("==> 1.5客户数据同步 同步数据出错了!"+e.getMessage()); e.printStackTrace(); } return rmFq; }; FutureTask<BaseResultMessage> rmFqTask = new FutureTask<>(rmFqCallable); new Thread(rmFqTask,"线程1,同步").start(); long endTimeFq = System.currentTimeMillis(); logger.error("==> 线程1,同步,当前线程:["+Thread.currentThread()+"]--》1.5客户数据同步 同步数据!花时:"+((endTimeFq-beginTimeFq)/1000)+"秒"); //======================================================= long beginTimeHn = System.currentTimeMillis(); Callable<BaseResultMessage> rmHnCallable = ()-> { try { return customerService.updateCustomerDataHn(customerBean); } catch (Exception e) { logger.error("==> 1.5客户数据同步 同步数据出错了!" + e.getMessage()); e.printStackTrace(); } return Utils.renderBaseResultMessageError(""); }; FutureTask<BaseResultMessage> rmHnTask = new FutureTask<>(rmHnCallable); new Thread(rmHnTask,"线程2,同步").start(); long endTimeHn = System.currentTimeMillis(); logger.error("==> 线程2,同步,当前线程:["+Thread.currentThread()+"]--》1.5客户数据同步 同步数据!花时:"+((endTimeHn-beginTimeHn)/1000)+"秒");