288 |
|
} |
289 |
|
|
290 |
|
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { |
291 |
< |
if (command == null) |
291 |
> |
if (command == null || unit == null) |
292 |
|
throw new NullPointerException(); |
293 |
|
long triggerTime = System.nanoTime() + unit.toNanos(delay); |
294 |
|
ScheduledFutureTask<?> t = new ScheduledFutureTask<Boolean>(command, null, triggerTime); |
297 |
|
} |
298 |
|
|
299 |
|
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { |
300 |
< |
if (callable == null) |
300 |
> |
if (callable == null || unit == null) |
301 |
|
throw new NullPointerException(); |
302 |
|
long triggerTime = System.nanoTime() + unit.toNanos(delay); |
303 |
|
ScheduledFutureTask<V> t = new ScheduledFutureTask<V>(callable, triggerTime); |
306 |
|
} |
307 |
|
|
308 |
|
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { |
309 |
< |
if (command == null) |
309 |
> |
if (command == null || unit == null) |
310 |
|
throw new NullPointerException(); |
311 |
|
if (period <= 0) |
312 |
|
throw new IllegalArgumentException(); |
321 |
|
} |
322 |
|
|
323 |
|
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { |
324 |
< |
if (command == null) |
324 |
> |
if (command == null || unit == null) |
325 |
|
throw new NullPointerException(); |
326 |
|
if (delay <= 0) |
327 |
|
throw new IllegalArgumentException(); |