void () { List<Runnable> runAfterUpdate = null; synchronized (myRunAfterUpdate) { if (!myRunAfterUpdate.isEmpty()) { runAfterUpdate = new ArrayList<>(myRunAfterUpdate); myRunAfterUpdate.clear(); } } if (runAfterUpdate != null) { for (Runnable r : runAfterUpdate) { r.run(); } } }