1 16 17 package org.springframework.scheduling.concurrent; 18 19 import java.util.concurrent.TimeUnit ; 20 21 43 public class ScheduledExecutorTask { 44 45 private Runnable runnable; 46 47 private long delay = 0; 48 49 private long period = -1; 50 51 private TimeUnit timeUnit = TimeUnit.MILLISECONDS; 52 53 private boolean fixedRate = false; 54 55 56 63 public ScheduledExecutorTask() { 64 } 65 66 71 public ScheduledExecutorTask(Runnable executorTask) { 72 this.runnable = executorTask; 73 } 74 75 81 public ScheduledExecutorTask(Runnable executorTask, long delay) { 82 this.runnable = executorTask; 83 this.delay = delay; 84 } 85 86 93 public ScheduledExecutorTask(Runnable executorTask, long delay, long period, boolean fixedRate) { 94 this.runnable = executorTask; 95 this.delay = delay; 96 this.period = period; 97 this.fixedRate = fixedRate; 98 } 99 100 101 104 public void setRunnable(Runnable executorTask) { 105 this.runnable = executorTask; 106 } 107 108 111 public Runnable getRunnable() { 112 return this.runnable; 113 } 114 115 120 public void setDelay(long delay) { 121 this.delay = delay; 122 } 123 124 127 public long getDelay() { 128 return this.delay; 129 } 130 131 145 public void setPeriod(long period) { 146 this.period = period; 147 } 148 149 152 public long getPeriod() { 153 return this.period; 154 } 155 156 161 public boolean isOneTimeTask() { 162 return (this.period <= 0); 163 } 164 165 171 public void setTimeUnit(TimeUnit timeUnit) { 172 this.timeUnit = (timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS); 173 } 174 175 178 public TimeUnit getTimeUnit() { 179 return this.timeUnit; 180 } 181 182 189 public void setFixedRate(boolean fixedRate) { 190 this.fixedRate = fixedRate; 191 } 192 193 196 public boolean isFixedRate() { 197 return this.fixedRate; 198 } 199 200 } 201 | Popular Tags |