
com.alibaba.ttl.threadpool.ExecutorTtlWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of transmittable-thread-local Show documentation
Show all versions of transmittable-thread-local Show documentation
a simple lib for transmitting ThreadLocal value between thread even using thread pool.
package com.alibaba.ttl.threadpool;
import com.alibaba.ttl.TtlRunnable;
import com.alibaba.ttl.TransmittableThreadLocal;
import java.util.concurrent.Executor;
/**
* {@link TransmittableThreadLocal} Wrapper of {@link Executor},
* transmit the {@link TransmittableThreadLocal} from the task submit time of {@link Runnable}
* to the execution time of {@link Runnable}.
*
* @author Jerry Lee (oldratlee at gmail dot com)
* @since 0.9.0
*/
class ExecutorTtlWrapper implements Executor {
final Executor executor;
public ExecutorTtlWrapper(Executor executor) {
this.executor = executor;
}
@Override
public void execute(Runnable command) {
executor.execute(TtlRunnable.get(command));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy