void () { final PackageManagementServiceEx serviceEx = getServiceEx(); if (serviceEx == null) { return; } int packageCount = myPackagesTableModel.getRowCount(); if (packageCount == 0) { onUpdateFinished(); } final AtomicInteger inProgressPackageCount = new AtomicInteger(packageCount); for (int i = 0; i < packageCount; ++i) { final int finalIndex = i; final InstalledPackage pkg = getInstalledPackageAt(finalIndex); serviceEx.fetchLatestVersion(pkg, new CatchingConsumer<>() { private void decrement() { if (inProgressPackageCount.decrementAndGet() == 0) { onUpdateFinished(); } } @Override public void consume(Exception e) { UIUtil.invokeLaterIfNeeded(() -> decrement()); LOG.warn("Cannot fetch the latest version of the installed package " + pkg, e); } @Override public void consume(@Nullable final String latestVersion) { UIUtil.invokeLaterIfNeeded(() -> { if (finalIndex < myPackagesTableModel.getRowCount()) { InstalledPackage p = getInstalledPackageAt(finalIndex); if (pkg == p) { myPackagesTableModel.setValueAt(latestVersion, finalIndex, 2); } } decrement(); }); } }); } }