public final class TtlRunnable extends Object implements Runnable
TtlRunnable decorate Runnable, so as to get TransmittableThreadLocal
and transmit it to the time of Runnable execution, needed when use Runnable to thread pool.
Use factory method get(Runnable) to create instance.
Executor,
ExecutorService,
ThreadPoolExecutor,
ScheduledThreadPoolExecutor,
Executors| Modifier and Type | Method and Description |
|---|---|
static TtlRunnable |
get(Runnable runnable)
Factory method, wrapper input
Runnable to TtlRunnable. |
static TtlRunnable |
get(Runnable runnable,
boolean releaseTtlValueReferenceAfterRun)
Factory method, wrapper input
Runnable to TtlRunnable. |
static TtlRunnable |
get(Runnable runnable,
boolean releaseTtlValueReferenceAfterRun,
boolean idempotent)
Factory method, wrapper input
Runnable to TtlRunnable. |
Runnable |
getRunnable()
return original/unwrapped
Runnable. |
static List<TtlRunnable> |
gets(Collection<? extends Runnable> tasks)
wrapper input
Runnable Collection to TtlRunnable Collection. |
static List<TtlRunnable> |
gets(Collection<? extends Runnable> tasks,
boolean releaseTtlValueReferenceAfterRun)
wrapper input
Runnable Collection to TtlRunnable Collection. |
static List<TtlRunnable> |
gets(Collection<? extends Runnable> tasks,
boolean releaseTtlValueReferenceAfterRun,
boolean idempotent)
wrapper input
Runnable Collection to TtlRunnable Collection. |
void |
run()
wrap method
Runnable.run(). |
public void run()
Runnable.run().public static TtlRunnable get(Runnable runnable)
runnable - input Runnable. if input is null, return null.RunnableIllegalStateException - when input is TtlRunnable already.public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun)
runnable - input Runnable. if input is null, return null.releaseTtlValueReferenceAfterRun - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.RunnableIllegalStateException - when input is TtlRunnable already.public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun, boolean idempotent)
runnable - input Runnable. if input is null, return null.releaseTtlValueReferenceAfterRun - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.idempotent - is idempotent or not. if , return input object when it's TtlRunnable, or throw IllegalStateException.
true will cover up bugs! DO NOT set, only when you know why.RunnableIllegalStateExceptionpublic static List<TtlRunnable> gets(Collection<? extends Runnable> tasks)
Runnable Collection to TtlRunnable Collection.tasks - task to be wrapped. if input is null, return null.IllegalStateException - when input is TtlRunnable already.public static List<TtlRunnable> gets(Collection<? extends Runnable> tasks, boolean releaseTtlValueReferenceAfterRun)
Runnable Collection to TtlRunnable Collection.tasks - task to be wrapped. if input is null, return null.releaseTtlValueReferenceAfterRun - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.IllegalStateException - when input is TtlRunnable already.public static List<TtlRunnable> gets(Collection<? extends Runnable> tasks, boolean releaseTtlValueReferenceAfterRun, boolean idempotent)
Runnable Collection to TtlRunnable Collection.tasks - task to be wrapped. if input is null, return null.releaseTtlValueReferenceAfterRun - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.idempotent - is idempotent or not. if , return input object when it's TtlRunnable, or throw IllegalStateException.
true will cover up bugs! DO NOT set, only when you know why.IllegalStateExceptionCopyright © 2013–2016 Alibaba. All rights reserved.