public synchronized void postAtFrontOfQueue ( Runnable runnable ) { if ( isPaused ( ) || Thread . currentThread ( ) != associatedThread ) { final long timeDisambiguator ; if ( runnables . isEmpty ( ) ) { timeDisambiguator = nextTimeDisambiguator ++ ; } else { timeDisambiguator = runnables . peek ( ) . timeDisambiguator - 1 ; } runnables . add ( new ScheduledRunnable ( runnable , 0 , timeDisambiguator ) ) ; } else { runOrQueueRunnable ( runnable , currentTime ) ; } }
Add a runnable to the head of the queue .