package com.helpshift.concurrency; import com.helpshift.log.HSLogger; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes3.dex */ public class NotifyingRunnable implements Runnable { public final Runnable runnable; public final Object syncLock = new Object(); public AtomicBoolean isFinished = new AtomicBoolean(false); public NotifyingRunnable(Runnable runnable) { this.runnable = runnable; } public void waitForCompletion() { synchronized (this.syncLock) { while (!this.isFinished.get()) { try { this.syncLock.wait(); } catch (InterruptedException e) { HSLogger.d("NotifyingRunnable", "Exception in NotifyingRunnable", e); Thread.currentThread().interrupt(); } } } } @Override // java.lang.Runnable public void run() { synchronized (this.syncLock) { try { try { this.runnable.run(); } finally { this.isFinished.set(true); this.syncLock.notifyAll(); } } catch (Throwable th) { throw th; } } } }