@Override public void run() { while (keepRunning) { List<Resource> resources = resourceSettings.getAllResources(); for (Resource resource : resources) { long lastUpdate; if (lastUpdateMap.containsKey(resource.getUrl())) { lastUpdate = lastUpdateMap.get(resource.getUrl()); } else { long currentTime = System.currentTimeMillis(); lastUpdateMap.put(resource.getUrl(), currentTime); lastUpdate = 0; } if (timeToUpdate(resource, lastUpdate)) { GenericResourceJob job = new GenericResourceJob(resource); executorService.submit(job); setUpdateTime(resource, System.currentTimeMillis()); } } try { Thread.sleep(sleepTime); } catch (InterruptedException e) { LOGGER.warning("Resource engine thread was interrupted: " + e.getMessage()); } } }
private void setUpdateTime(final Resource resource, final long time) { lastUpdateMap.put(resource.getUrl(), time); }