package o; import android.os.Handler; import android.os.HandlerThread; import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fOt, reason: case insensitive filesystem */ /* loaded from: classes5.dex */ public final class C13039fOt implements InterfaceC13042fOw { private int b; private int c; private String d; private final LinkedList f = new LinkedList<>(); final LinkedList a = new LinkedList<>(); final LinkedList e = new LinkedList<>(); /* JADX INFO: Access modifiers changed from: package-private */ public C13039fOt(String str, int i, int i2) { this.d = str; this.c = i; this.b = i2; } @Override // o.InterfaceC13042fOw public final void a() { synchronized (this) { for (int i = 0; i < this.c; i++) { StringBuilder sb = new StringBuilder(); sb.append(this.d); sb.append(i); final C13034fOo c13034fOo = new C13034fOo(sb.toString(), this.b); Runnable runnable = new Runnable(this, c13034fOo) { // from class: o.fOv private C13039fOt d; private C13034fOo e; @Override // java.lang.Runnable public final void run() { C13039fOt c13039fOt = this.d; C13034fOo c13034fOo2 = this.e; synchronized (c13039fOt) { c13039fOt.d(c13034fOo2); if (c13034fOo2.e()) { c13039fOt.e.remove(c13034fOo2); c13039fOt.a.add(c13034fOo2); } } } { this.d = this; this.e = c13034fOo; } }; synchronized (c13034fOo) { HandlerThread handlerThread = new HandlerThread(c13034fOo.b, c13034fOo.h); c13034fOo.d = handlerThread; handlerThread.start(); c13034fOo.e = new Handler(c13034fOo.d.getLooper()); c13034fOo.f = runnable; } this.a.add(c13034fOo); } } } @Override // o.InterfaceC13042fOw public final void e() { synchronized (this) { Iterator it = this.a.iterator(); while (it.hasNext()) { it.next().b(); } Iterator it2 = this.e.iterator(); while (it2.hasNext()) { it2.next().b(); } } } @Override // o.InterfaceC13042fOw public final void d(C13032fOm c13032fOm, Runnable runnable) { synchronized (this) { C13035fOp c13035fOp = new C13035fOp(c13032fOm, runnable); if (this.f.isEmpty()) { Iterator it = this.e.iterator(); while (it.hasNext()) { if (it.next().d(c13035fOp)) { return; } } } this.f.add(c13035fOp); Iterator it2 = this.a.iterator(); while (it2.hasNext()) { C13034fOo next = it2.next(); d(next); if (next.d()) { this.e.add(next); this.a.remove(next); return; } } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void d(C13034fOo c13034fOo) { synchronized (this) { ListIterator listIterator = this.f.listIterator(); while (true) { if (!listIterator.hasNext()) { break; } else if (c13034fOo.d(listIterator.next())) { listIterator.remove(); break; } } while (listIterator.hasNext() && c13034fOo.d(listIterator.next())) { listIterator.remove(); } } } }