| 1 24 package org.riotfamily.riot.job.support; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 import org.riotfamily.riot.job.JobContext; 29 30 37 public class ExecutionTimeUpdater implements Runnable { 38 39 private Log log = LogFactory.getLog(ExecutionTimeUpdater.class); 40 41 private TaskList taskList; 42 43 private long updateInterval = 15000; 44 45 private volatile Thread thread; 46 47 public ExecutionTimeUpdater(TaskList taskList) { 48 this.taskList = taskList; 49 } 50 51 public void setUpdateInterval(long updateInterval) { 52 this.updateInterval = updateInterval; 53 } 54 55 public void stop() { 56 Thread thread = this.thread; 57 this.thread = null; 58 thread.interrupt(); 59 } 60 61 public void run() { 62 thread = Thread.currentThread(); 63 while (thread != null) { 64 taskList.updateExecutionTimes(); 65 try { 66 Thread.sleep(updateInterval); 67 taskList.waitForTasks(); 68 } 69 catch (InterruptedException e) { 70 } 71 } 72 log.info("ExecutionTimeUpdater has been stopped."); 73 } 74 75 } 76 | Popular Tags |