Source:
<code>private IStatus updateElements(IWorkingSet[] workingSets, IProgressMonitor monitor) { try { if(isDisposed.get() || monitor.isCanceled()) { return Status.CANCEL_STATUS; } IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IJavaModel model= JavaCore.create(root); List<IAdaptable> testResult= new ArrayList<>(); List<IAdaptable> mainResult= new ArrayList<>(); IJavaProject[] jProjects= model.getJavaProjects(); for (int i= 0; i < jProjects.length; i++) { if (monitor.isCanceled() || isDisposed.get()) return Status.CANCEL_STATUS; final IJavaProject project= jProjects[i]; if (project.getProject().isOpen()) { for (IPackageFragmentRoot iPackageFragmentRoot : project.getPackageFragmentRoots()) { IClasspathEntry classpathEntry= iPackageFragmentRoot.getRawClasspathEntry(); if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (classpathEntry.isTest()) { testResult.add(iPackageFragmentRoot); } else { mainResult.add(iPackageFragmentRoot); } } } } } IAdaptable[] testArray= testResult.toArray(new IAdaptable[testResult.size()]); IAdaptable[] productionArray= mainResult.toArray(new IAdaptable[mainResult.size()]); <START> if (PlatformUI.isWorkbenchRunning()) { final Display display= PlatformUI.getWorkbench().getDisplay(); if (!display.isDisposed()) { <END> fUpdateUIJob.setTask(() -> { for (IWorkingSet w : workingSets) { if (MAIN_NAME.equals(w.getName())) { w.setElements(productionArray); } else if (TEST_NAME.equals(w.getName())) { w.setElements(testArray); } } }); } } } catch (Exception e) { return Status.CANCEL_STATUS; } return Status.OK_STATUS; }</code><technical_language>checks removed (this is actual advantage of introducing fUpdateUIJob, right?)</technical_language>

Target:
private IStatus updateElements(IWorkingSet[] workingSets, IProgressMonitor monitor) { try { if(isDisposed.get()) { return Status.CANCEL_STATUS; } IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IJavaModel model= JavaCore.create(root); List<IAdaptable> testResult= new ArrayList<>(); List<IAdaptable> mainResult= new ArrayList<>(); IJavaProject[] jProjects= model.getJavaProjects(); for (int i= 0; i < jProjects.length; i++) { if (monitor.isCanceled() || isDisposed.get()) return Status.CANCEL_STATUS; final IJavaProject project= jProjects[i]; if (project.getProject().isOpen()) { for (IPackageFragmentRoot iPackageFragmentRoot : project.getPackageFragmentRoots()) { IClasspathEntry classpathEntry= iPackageFragmentRoot.getRawClasspathEntry(); if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (classpathEntry.isTest()) { testResult.add(iPackageFragmentRoot); } else { mainResult.add(iPackageFragmentRoot); } } } } } IAdaptable[] testArray= testResult.toArray(new IAdaptable[testResult.size()]); IAdaptable[] productionArray= mainResult.toArray(new IAdaptable[mainResult.size()]); if (PlatformUI.isWorkbenchRunning()) { final Display display= PlatformUI.getWorkbench().getDisplay(); if (!display.isDisposed()) { display.asyncExec(() -> { for (IWorkingSet w : workingSets) { if (MAIN_NAME.equals(w.getName())) { w.setElements(productionArray); } else if (TEST_NAME.equals(w.getName())) { w.setElements(testArray); } } }); } } } catch (Exception e) { return Status.CANCEL_STATUS; } return Status.OK_STATUS; }