/** * 添加 时间点-计划任务 * * @param TaskTrigger */ public void putTaskTrigger(TaskTrigger TaskTrigger) { if (TaskTrigger != null) { List<TaskTrigger> TaskTriggerList = triggerMap.get(TaskTrigger.getTime()); // 如果该时间点已经存在要执行的计划任务,那么就添加到该时间点对应的集合中 if (TaskTriggerList != null && TaskTriggerList.size() > 0) { TaskTriggerList.add(TaskTrigger); triggerMap.put(TaskTrigger.getTime(), TaskTriggerList); } else { // 否则往时间触发器树里面增加一个元素 timeTriggers.add(TaskTrigger.getTime()); // triggerMap里面添加一个一对 key-value List<TaskTrigger> newTaskTriggerList = new ArrayList<>(); newTaskTriggerList.add(TaskTrigger); triggerMap.put(TaskTrigger.getTime(), newTaskTriggerList); } } }
public void removeTaskTrigger(TaskTrigger TaskTrigger) { if (TaskTrigger != null) { timeTriggers.remove(TaskTrigger.getTime()); } }