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 methods get(java.lang.Runnable) / gets(java.util.Collection<? extends java.lang.Runnable>) to create instance.
Executor,
ExecutorService,
ThreadPoolExecutor,
ScheduledThreadPoolExecutor,
Executors| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
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. |
int |
hashCode() |
void |
run()
wrap method
Runnable.run(). |
String |
toString() |
public void run()
Runnable.run().public static TtlRunnable get(Runnable runnable)
Runnable to TtlRunnable.runnable - input Runnable. if input is null, return null.RunnableIllegalStateException - when input is TtlRunnable already.public static TtlRunnable get(Runnable runnable, boolean releaseTtlValueReferenceAfterRun)
Runnable to TtlRunnable.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 to TtlRunnable.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 mode or not. if true, just return input Runnable when it's TtlRunnable,
otherwise throw IllegalStateException.
Caution: true will cover up bugs! DO NOT set, only when you know why.RunnableIllegalStateException - when input is TtlRunnable already and not idempotent.public 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 mode or not. if true, just return input Runnable when it's TtlRunnable,
otherwise throw IllegalStateException.
Caution: true will cover up bugs! DO NOT set, only when you know why.IllegalStateException - when input is TtlRunnable already and not idempotent.Copyright © 2013–2017 Alibaba. All rights reserved.