我有两个任务,每天安排两次,时间不同。
示例:
- Task1计划于上午11点和下午3点
- 任务2计划于下午2点和下午5点
醇>
我想检查任务是否已经安排在同一时间?
ScheduledExecutorService executor1 = Executors.newScheduledThreadPool(MYTHREADS);
String[] hostList = { "http://crunchify.com","http://yahoo.com"}; //Two Tasks
String[] timings = {"11:0,15:0","10:0,17:0"}; //(11AM,3PM) and (10AM,5PM) scheduled timings twice a day
for (int i = 0; i < hostList.length; i++) {
String url = hostList[i];
Runnable worker = new MyRunnable(url);
String[] schedulingHour = timings[i].split(",");
for(int j=0;j<schedulingHour.length;j++){
executor1.schedule(worker,getTimeUntilTarget(Integer.parseInt(schedulingHour[j].split(":")[0]),Integer.parseInt(schedulingHour[j].split(":")[1])), TimeUnit.MILLISECONDS);
}
}