package com.tencent.mm.at.a.a;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.at.a.c.h;
import com.tencent.mm.sdk.platformtools.ab;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

class a$c extends ThreadPoolExecutor implements h {
    private ReentrantLock eRw = new ReentrantLock();
    private Condition eRx = this.eRw.newCondition();
    private BlockingQueue<Runnable> eRy;
    private boolean isPaused;

    public a$c(int i, int i2, TimeUnit timeUnit, BlockingQueue<Runnable> blockingQueue, ThreadFactory threadFactory) {
        super(i, i2, 0, timeUnit, blockingQueue, threadFactory);
        AppMethodBeat.i(116058);
        this.eRy = blockingQueue;
        AppMethodBeat.o(116058);
    }

    /* Access modifiers changed, original: protected|final */
    public final void beforeExecute(Thread thread, Runnable runnable) {
        AppMethodBeat.i(116059);
        super.beforeExecute(thread, runnable);
        this.eRw.lock();
        while (this.isPaused) {
            try {
                this.eRx.await();
            } catch (Exception e) {
                thread.interrupt();
                ab.w("MicroMsg.imageloader.DefaultThreadPoolExecutor", "[cpan] before execute exception:%s", new Object[]{e.toString()});
            } finally {
                this.eRw.unlock();
                AppMethodBeat.o(116059);
            }
        }
    }

    public final void pause() {
        AppMethodBeat.i(116060);
        this.eRw.lock();
        try {
            this.isPaused = true;
        } finally {
            this.eRw.unlock();
            AppMethodBeat.o(116060);
        }
    }

    public final void resume() {
        AppMethodBeat.i(116061);
        this.eRw.lock();
        try {
            this.isPaused = false;
            this.eRx.signalAll();
        } finally {
            this.eRw.unlock();
            AppMethodBeat.o(116061);
        }
    }

    public final void execute(Runnable runnable) {
        AppMethodBeat.i(116062);
        super.execute(runnable);
        AppMethodBeat.o(116062);
    }

    public final boolean DA() {
        return this.isPaused;
    }

    public final void remove(Object obj) {
        AppMethodBeat.i(116063);
        if (this.eRy != null) {
            this.eRy.remove(obj);
        }
        AppMethodBeat.o(116063);
    }
}
