@@ -0,0 +1,2160 @@
+package com.alibaba.mtc;%0A%0Aimport java.util.Map;%0Aimport java.util.TimerTask;%0A%0A/**%0A * %7B@link MtContextTimerTask%7D decorate %7B@link Runnable%7D, so as to get @%7B@link MtContext%7D%0A * and transmit it to the time of %7B@link Runnable%7D execution, needed when use %7B@link Runnable%7D to thread pool.%0A * %3Cp/%3E%0A * Use factory method %7B@link #get(TimerTask)%7D to create instance.%0A * %3Cp/%3E%0A * Use %7B@link java.util.concurrent.ScheduledThreadPoolExecutor%7D instead %7B@link java.util.Timer%7D%0A *%0A * @author ding.lid%0A * @see java.util.Timer%0A * @see TimerTask%0A * @since 0.9.0%0A */%0A@Deprecated%0Apublic final class MtContextTimerTask extends TimerTask %7B%0A    private final Map%3CString, Object%3E content;%0A    private final TimerTask timerTask;%0A%0A    private MtContextTimerTask(TimerTask timerTask) %7B%0A        content = MtContext.getContext().getWithCopy();%0A        this.timerTask = timerTask;%0A    %7D%0A%0A    /**%0A     * wrap method %7B@link TimerTask#run()%7D.%0A     */%0A    @Override%0A    public void run() %7B%0A        MtContext mtContext = MtContext.getContext();%0A        final Map%3CString, Object%3E old = mtContext.get0();%0A        try %7B%0A            mtContext.set0(content);%0A            timerTask.run();%0A        %7D finally %7B%0A            mtContext.set0(old); // restore MtContext%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean cancel() %7B%0A        return timerTask.cancel();%0A    %7D%0A%0A    @Override%0A    public long scheduledExecutionTime() %7B%0A        return timerTask.scheduledExecutionTime();%0A    %7D%0A%0A    public TimerTask getTimerTask() %7B%0A        return timerTask;%0A    %7D%0A%0A    /**%0A     * Factory method, wrapper input %7B@link Runnable%7D to %7B@link MtContextTimerTask%7D.%0A     * %3Cp/%3E%0A     * This method is idempotent.%0A     *%0A     * @param timerTask input %7B@link TimerTask%7D%0A     * @return Wrapped %7B@link TimerTask%7D%0A     */%0A    public static MtContextTimerTask get(TimerTask timerTask) %7B%0A        if (null == timerTask) %7B%0A            throw new NullPointerException(%22runnable argument is null!%22);%0A        %7D%0A%0A        if (timerTask instanceof MtContextTimerTask) %7B // avoid redundant decoration, and ensure idempotency%0A            return (MtContextTimerTask) timerTask;%0A        %7D%0A        return new MtContextTimerTask(timerTask);%0A    %7D%0A%7D%0A

add MtContextTimerTask