package com.google.android.m4b.maps.af;

import java.util.Vector;

public final class c
  implements Runnable
{
  private Vector<b> a = new Vector();
  private Vector<d> b = new Vector();
  private Object c = new Object();
  private com.google.android.m4b.maps.z.b d;
  private com.google.android.m4b.maps.ae.b e;
  private Thread[] f;
  private String g;
  private int h = 127;
  private boolean i = false;

  public c(com.google.android.m4b.maps.ae.b paramb)
  {
    this(paramb, "TaskRunner", 1);
  }

  private c(com.google.android.m4b.maps.ae.b paramb, String paramString, int paramInt)
  {
    this.e = paramb;
    this.g = paramString;
    this.f = new Thread[1];
    this.d = com.google.android.m4b.maps.z.a.a().b();
  }

  private boolean c()
  {
    if ((this.i) && (this.a.isEmpty()));
    try
    {
      if (this.b.isEmpty())
        this.c.wait();
      while (true)
      {
        return this.i;
        long l = ((d)this.b.elementAt(0)).i() - this.d.a();
        if (l > 0L)
          this.c.wait(l);
      }
    }
    catch (InterruptedException localInterruptedException)
    {
      while (true)
        localInterruptedException.printStackTrace();
    }
  }

  private b d()
  {
    while (!this.b.isEmpty())
    {
      d locald = (d)this.b.elementAt(0);
      if (locald.i() - this.d.a() > 0L)
        break;
      this.b.removeElementAt(0);
      a(locald);
    }
    if (!this.a.isEmpty())
    {
      b localb = (b)this.a.elementAt(0);
      localb.a(3);
      this.a.removeElementAt(0);
      return localb;
    }
    return null;
  }

  final int a()
  {
    return this.h;
  }

  final void a(a parama)
  {
    while (true)
    {
      synchronized (this.c)
      {
        switch (parama.c())
        {
        case 1:
        case 2:
        default:
          return;
        case 0:
          parama.e();
        case 3:
        }
      }
      parama.a(4);
    }
  }

  final void a(b paramb)
  {
    while (true)
    {
      int i1;
      synchronized (this.c)
      {
        int j = paramb.h();
        int k = this.a.size();
        int m = 0;
        n = k;
        if (m < n)
        {
          i1 = (m + n) / 2;
          if (j > ((b)this.a.elementAt(i1)).h())
            break label104;
          m = i1 + 1;
          continue;
        }
        this.a.insertElementAt(paramb, m);
        paramb.a(2);
        this.c.notifyAll();
        return;
      }
      label104: int n = i1;
    }
  }

  final void a(d paramd)
  {
    while (true)
    {
      int n;
      synchronized (this.c)
      {
        long l = paramd.i();
        int j = this.b.size();
        int k = 0;
        m = j;
        if (k < m)
        {
          n = (k + m) / 2;
          if (l < ((d)this.b.elementAt(n)).i())
            break label105;
          k = n + 1;
          continue;
        }
        this.b.insertElementAt(paramd, k);
        paramd.a(1);
        this.c.notifyAll();
        return;
      }
      label105: int m = n;
    }
  }

  public final int b(a parama)
  {
    synchronized (this.c)
    {
      int j = parama.b();
      return j;
    }
  }

  public final void b()
  {
    synchronized (this.c)
    {
      if (!this.i)
      {
        this.i = true;
        for (int j = 0; j < this.f.length; j++)
        {
          this.f[j] = this.e.a(this.g + "-" + j, this);
          this.f[j].start();
        }
      }
      return;
    }
  }

  final boolean c(a parama)
  {
    synchronized (this.c)
    {
      int j = parama.c();
      switch (j)
      {
      default:
        return false;
      case 1:
        this.b.removeElement(parama);
        parama.a(0);
        this.c.notifyAll();
        return true;
      case 2:
      case 3:
      case 4:
      }
    }
    this.a.removeElement(parama);
    parama.a(0);
    this.c.notifyAll();
    return true;
    parama.a(0);
    return false;
  }

  public final void run()
  {
    b localb = null;
    while (true)
    {
      Object localObject1 = this.c;
      if (localb != null);
      try
      {
        if (localb.c() == 4)
        {
          localb.a(0);
          localb.e();
        }
        while (!c())
        {
          return;
          if (localb.c() == 3)
            localb.a(0);
        }
      }
      finally
      {
      }
      localb = d();
      if (localb != null)
        try
        {
          localb.g();
        }
        catch (Throwable localThrowable)
        {
          localThrowable.printStackTrace();
        }
    }
  }

  public final String toString()
  {
    return super.toString();
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.google.android.m4b.maps.af.c
 * JD-Core Version:    0.6.2
 */