public static void main(String[] arg) { DelayRunner.getInstance().start(); // DelayRunner.getInstance().startSession("recommend_id",); // DelayRunner.getInstance().startSession("list_channel_id"); for (int i = 0; i < 100; i++) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); break; } } DelayRunner.getInstance().stopDelayRunner(); }
// 定义获取该线程的静态实例,当该线程没有启动时,则立即启动它 public static DelayRunner getInstance() { if (!instance.isAlive()) { instance.start(); } return instance; }