FeedRenderingPool { public SynchronizationControl synchronizeTime(final long syncTime) { final Set<FeedView> syncedManifestations = new HashSet<FeedView>(); SynchronizationControl sc = new SynchronizationControl() { @Override public void update(long syncTime) { Map<FeedProvider, Long[]> times = new HashMap<FeedProvider,Long[]>(); for (FeedView manifestation:activeFeedViews) { for (FeedProvider provider:manifestation.getVisibleFeedProviders()) { times.put(provider, new Long[]{syncTime-2000, syncTime}); } } FeedCycleRenderer renderer = createSyncWorker(syncTime, times, activeFeedViews, syncedManifestations); try { renderer.execute(); } catch (Exception e) { LOGGER.error(e); } } @Override public void synchronizationDone() { activeSyncControl.set(null); for(FeedView m : syncedManifestations) { m.synchronizationDone(); } } }; if (!activeSyncControl.compareAndSet(null, sc)) { return null; } Map<FeedProvider, Long[]> times = new HashMap<FeedProvider,Long[]>(); for (FeedView manifestation:activeFeedViews) { for (FeedProvider provider:manifestation.getVisibleFeedProviders()) { times.put(provider, new Long[]{syncTime-2000, syncTime}); } } FeedCycleRenderer renderer = createSyncWorker(syncTime, times, activeFeedViews, syncedManifestations); try { renderer.execute(); } catch (Exception e) { LOGGER.error(e); sc.synchronizationDone(); sc = null; } return sc; } FeedRenderingPool(int paintRateInterval); void addFeedView(FeedView manifestation); void removeFeedView(FeedView manifestation); SynchronizationControl synchronizeTime(final long syncTime);  }
@Test public void testSynchronizeTime() { pool.addFeedView(fv1); SynchronizationControl sc = pool.synchronizeTime(System.currentTimeMillis() - 2); Assert.assertNotNull(sc); Assert.assertNull(pool.synchronizeTime(System.currentTimeMillis())); sc.synchronizationDone(); Assert.assertNotNull(pool.synchronizeTime(System.currentTimeMillis())); }