void () { final Runnable[] tasks; synchronized (myPendingTasks) { tasks = myPendingTasks.toArray(ArrayUtil.EMPTY_RUNNABLE_ARRAY); myPendingTasks.clear(); } for (Runnable task : tasks) { task.run(); } }