public class NewThreadWorker extends Scheduler.Worker implements Disposable
Constructor and Description |
---|
NewThreadWorker(ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
Disposable |
schedule(Runnable run)
Schedules a Runnable for execution without any time delay.
|
Disposable |
schedule(Runnable action,
long delayTime,
TimeUnit unit)
Schedules an Runnable for execution at some point in the future specified by a time delay
relative to the current time.
|
ScheduledRunnable |
scheduleActual(Runnable run,
long delayTime,
TimeUnit unit,
DisposableContainer parent)
Wraps the given runnable into a ScheduledRunnable and schedules it
on the underlying ScheduledExecutorService.
|
Disposable |
scheduleDirect(Runnable run,
long delayTime,
TimeUnit unit)
Schedules the given runnable on the underlying executor directly and
returns its future wrapped into a Disposable.
|
Disposable |
schedulePeriodicallyDirect(Runnable run,
long initialDelay,
long period,
TimeUnit unit)
Schedules the given runnable periodically on the underlying executor directly
and returns its future wrapped into a Disposable.
|
void |
shutdown()
Shuts down the underlying executor in a non-interrupting fashion.
|
now, schedulePeriodically
public NewThreadWorker(ThreadFactory threadFactory)
@NonNull public Disposable schedule(@NonNull Runnable run)
Scheduler.Worker
The default implementation delegates to Scheduler.Worker.schedule(Runnable, long, TimeUnit)
.
schedule
in class Scheduler.Worker
run
- Runnable to schedule@NonNull public Disposable schedule(@NonNull Runnable action, long delayTime, @NonNull TimeUnit unit)
Scheduler.Worker
Note to implementors: non-positive delayTime
should be regarded as non-delayed schedule, i.e.,
as if the Scheduler.Worker.schedule(Runnable)
was called.
schedule
in class Scheduler.Worker
action
- the Runnable to scheduledelayTime
- time to "wait" before executing the action; non-positive values indicate an non-delayed
scheduleunit
- the time unit of delayTime
public Disposable scheduleDirect(Runnable run, long delayTime, TimeUnit unit)
run
- the Runnable to execute in a delayed fashiondelayTime
- the delay amountunit
- the delay time unitpublic Disposable schedulePeriodicallyDirect(Runnable run, long initialDelay, long period, TimeUnit unit)
run
- the Runnable to execute in a periodic fashioninitialDelay
- the initial delay amountperiod
- the repeat period amountunit
- the time unit for both the initialDelay and period@NonNull public ScheduledRunnable scheduleActual(Runnable run, long delayTime, @NonNull TimeUnit unit, @Nullable DisposableContainer parent)
If the schedule has been rejected, the ScheduledRunnable.wasScheduled will return false.
run
- the runnable instancedelayTime
- the time to delay the executionunit
- the time unitparent
- the optional tracker parent to add the created ScheduledRunnable instance to before it gets scheduledpublic void dispose()
Disposable
dispose
in interface Disposable
public void shutdown()
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
Copyright © 2018 JBoss by Red Hat. All rights reserved.