public void run() {
        int emptyCount = 0;
        long scheduleTickTime = System.nanoTime();
        boolean isShutDown = false;
        activeDispatchers.incrementAndGet();
        try {
            while( ! isShutDown ) {
                try {
                    if ( pollQs() ) {
                        emptyCount = 0;
                        if ( System.nanoTime() - scheduleTickTime > SCHEDULE_TICK_NANOS) {
                            if ( emptySinceLastCheck == 0 ) // no idle during last interval
                            {
                                checkForSplit();
                            }
                            emptySinceLastCheck = 0;
                            scheduleTickTime = System.nanoTime();
                            schedulePendingAdds();
                        }
                    }
                    else {
                        emptyCount++;
                        emptySinceLastCheck++;
                        scheduler.pollDelay(emptyCount);
                        if (shutDown) // access volatile only when idle
                            isShutDown = true;
                        if ( scheduler.getBackoffStrategy().isSleeping(emptyCount) ) {
                            scheduleTickTime = 0;
                            schedulePendingAdds();
                            if ( System.currentTimeMillis()-created > 5000 ) {
                                if ( autoShutDown && actors.length == 0 && toAdd.peek() == null) {
                                    shutDown();
                                } else {
                                    scheduler.tryStopThread(this);
                                }
                            }
                        }
                    }
                } catch (Throwable th) {
                    Log.Warn(this, th, "from main poll loop");
                }
            }
            scheduler.threadStopped(this);
            LockSupport.parkNanos(1000*1000*1000);
            if ( actors.length > 0 || toAdd.peek() != null ) {
                if ( SimpleScheduler.DEBUG_SCHEDULING)
                    Log.Lg.warn(this, "zombie dispatcher thread detected. This can be a debugging artifact.");
                scheduler.tryStopThread(this);
            }
            if ( SimpleScheduler.DEBUG_SCHEDULING)
                Log.Debug(this,"dispatcher thread terminated "+getName());
        } finally {
            activeDispatchers.decrementAndGet();
        }
    }
public void run ( ) { int emptyCount = 0 ; long scheduleTickTime = System . nanoTime ( ) ; boolean isShutDown = false ; activeDispatchers . incrementAndGet ( ) ; try { while ( ! isShutDown ) { try { if ( pollQs ( ) ) { emptyCount = 0 ; if ( System . nanoTime ( ) - scheduleTickTime > SCHEDULE_TICK_NANOS ) { if ( emptySinceLastCheck == 0 ) { checkForSplit ( ) ; } emptySinceLastCheck = 0 ; scheduleTickTime = System . nanoTime ( ) ; schedulePendingAdds ( ) ; } } else { emptyCount ++ ; emptySinceLastCheck ++ ; scheduler . pollDelay ( emptyCount ) ; if ( shutDown ) isShutDown = true ; if ( scheduler . getBackoffStrategy ( ) . isSleeping ( emptyCount ) ) { scheduleTickTime = 0 ; schedulePendingAdds ( ) ; if ( System . currentTimeMillis ( ) - created > 5000 ) { if ( autoShutDown && actors . length == 0 && toAdd . peek ( ) == null ) { shutDown ( ) ; } else { scheduler . tryStopThread ( this ) ; } } } } } catch ( Throwable th ) { Log . Warn ( this , th , "from main poll loop" ) ; } } scheduler . threadStopped ( this ) ; LockSupport . parkNanos ( 1000 * 1000 * 1000 ) ; if ( actors . length > 0 || toAdd . peek ( ) != null ) { if ( SimpleScheduler . DEBUG_SCHEDULING ) Log . Lg . warn ( this , "zombie dispatcher thread detected. This can be a debugging artifact." ) ; scheduler . tryStopThread ( this ) ; } if ( SimpleScheduler . DEBUG_SCHEDULING ) Log . Debug ( this , "dispatcher thread terminated " + getName ( ) ) ; } finally { activeDispatchers . decrementAndGet ( ) ; } }
incremented on sleep/all