void () { final NavBarItem[] toDispose = myList.toArray(new NavBarItem[0]); myList.clear(); ApplicationManager.getApplication().executeOnPooledThread(() -> { for (NavBarItem item : toDispose) { Disposer.dispose(item); } }); getNavBarUI().clearItems(); }