package com.google.common.util.concurrent; import com.google.common.base.Preconditions; import java.util.concurrent.Executor; import java.util.logging.Level; import java.util.logging.Logger; /* loaded from: classes2.dex */ public final class ExecutionList { private static final Logger log = Logger.getLogger(ExecutionList.class.getName()); private boolean executed; private RunnableExecutorPair runnables; public final void add(Runnable runnable, Executor executor) { Preconditions.checkNotNull(runnable, "Runnable was null."); Preconditions.checkNotNull(executor, "Executor was null."); synchronized (this) { if (!this.executed) { this.runnables = new RunnableExecutorPair(runnable, executor, this.runnables); } else { executeListener(runnable, executor); } } } public final void execute() { synchronized (this) { if (this.executed) { return; } this.executed = true; RunnableExecutorPair runnableExecutorPair = this.runnables; RunnableExecutorPair runnableExecutorPair2 = null; this.runnables = null; while (runnableExecutorPair != null) { RunnableExecutorPair runnableExecutorPair3 = runnableExecutorPair.next; runnableExecutorPair.next = runnableExecutorPair2; runnableExecutorPair2 = runnableExecutorPair; runnableExecutorPair = runnableExecutorPair3; } while (runnableExecutorPair2 != null) { executeListener(runnableExecutorPair2.runnable, runnableExecutorPair2.executor); runnableExecutorPair2 = runnableExecutorPair2.next; } } } private static void executeListener(Runnable runnable, Executor executor) { try { executor.execute(runnable); } catch (RuntimeException e) { Logger logger = log; Level level = Level.SEVERE; String valueOf = String.valueOf(runnable); String valueOf2 = String.valueOf(executor); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 57 + String.valueOf(valueOf2).length()); sb.append("RuntimeException while executing runnable "); sb.append(valueOf); sb.append(" with executor "); sb.append(valueOf2); logger.log(level, sb.toString(), (Throwable) e); } } /* loaded from: classes2.dex */ static final class RunnableExecutorPair { final Executor executor; RunnableExecutorPair next; final Runnable runnable; RunnableExecutorPair(Runnable runnable, Executor executor, RunnableExecutorPair runnableExecutorPair) { this.runnable = runnable; this.executor = executor; this.next = runnableExecutorPair; } } }