void () { WeakReference<ServiceViewItem> oldValueRef = new WeakReference<>(myRef.get()); ServiceViewItem newValue = ContainerUtil.getOnlyItem(getModel().getRoots()); WeakReference<ServiceViewItem> newValueRef = new WeakReference<>(newValue); myRef.set(newValue); AppUIExecutor.onUiThread().expireWith(this).submit(() -> { if (mySelected) { ServiceViewItem value = newValueRef.get(); if (value != null) { ServiceViewDescriptor descriptor = value.getViewDescriptor(); if (oldValueRef.get() == null) { onViewSelected(descriptor); } myUi.setDetailsComponent(descriptor.getContentComponent()); } } }); }