r = (Runnable) queue.remove (0);
r = (queue.isEmpty() ? null : (Runnable)queue.remove(0));
    public void run()     {      Runnable r;      while (!quitNow)       {        synchronized (this)         {          while (!quitNow && queue.isEmpty())           {            //  Set available for work            if (doDebug()) log.debug ("WorkQueue: Waiting for work: " +this);            setAvailable (true);            //  Wait for new work or idle timeout             long startWait = now();            try { wait (idleTimeout); } catch (Exception e) {}            int waitTime = (int) (now() - startWait);            //  Check if time to prune this thread            if (idleTimeout > 0 && waitTime >= idleTimeout && queue.isEmpty())            {              if (doDebug()) log.debug ("WorkQueue: Idle timeout - exiting: " +this);              removeThread (this);              return;            }            else if (quitNow) return;          }          r = (Runnable) queue.remove (0);          if (r != null)          {            if (doDebug()) log.debug ("WorkQueue: Got work: " +this);            setAvailable (false);          }          else continue;        }        try         {          r.run();        }        catch (Exception e)         {          if (log.isWarnEnabled()) log.warn ("WorkQueue: Runnable "+r+" got exception: "+e);        }        r = null;  // allow gc      }    }