com.alibaba.mtc.threadpool.ExecutorMtcWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multithread.context Show documentation
Show all versions of multithread.context Show documentation
a simple lib for transmitting context between thread even using thread pool.
package com.alibaba.mtc.threadpool;
import com.alibaba.mtc.MtContextRunnable;
import java.util.concurrent.Executor;
/**
* {@link com.alibaba.mtc.MtContextThreadLocal} Wrapper of {@link Executor},
* transmit the {@link com.alibaba.mtc.MtContextThreadLocal} from the task submit time of {@link Runnable}
* to the execution time of {@link Runnable}.
*
* @author ding.lid
* @since 0.9.0
*/
class ExecutorMtcWrapper implements Executor {
final Executor executor;
public ExecutorMtcWrapper(Executor executor) {
this.executor = executor;
}
@Override
public void execute(Runnable command) {
executor.execute(MtContextRunnable.get(command));
}
}