public void flush(){
  LinkedList<Runnable> queue=new LinkedList<>();
synchronized (mQueue) {
    queue.addAll(mQueue);
    mQueue.clear();
  }
  for (  Runnable r : queue) {
    r.run();
  }
}

public void flush ( ) { LinkedList < Runnable > queue = new LinkedList < > ( ) ; synchronized ( mQueue ) { queue . addAll ( mQueue ) ; mQueue . clear ( ) ; } for ( Runnable r : queue ) { r . run ( ) ; } }
runs all queued runnables from the calling thread .
