new Thread((new Runnable() { @Override public void run() { // 批量同步数据 try { logger.info("^^^^^^^^^^^^^^^^^ sync start ^^^^^^^^^^^^^^^^^ "); logger.info("^^^^^^^^^^^^^^^^^ sync end ^^^^^^^^^^^^^^^^^ "); } catch (IOException e) { LogUtils2.error("", e); } } })).start();
private ExecutorService executor = Executors.newFixedThreadPool(1); executor.submit(new Runnable() { @Override public void run() { // 批量同步数据 try { logger.info("^^^^^^^^^^^^^^^^^ sync weinxi data start ^^^^^^^^^^^^^^^^^ "); weiXinUsersService.batchSaveHandle(); logger.info("^^^^^^^^^^^^^^^^^ sync weinxi data end ^^^^^^^^^^^^^^^^^ "); } catch (IOException e) { LogUtils2.error("", e); } } });
spring boot:
@EnableAsync public class WeiXinUsersService extends BaseGongfuService { @Async public void batchSaveHandle() throws IOException { } }