@Test public void testGetCurrent() throws Exception { BackgroundActionRegistry r = new BackgroundActionRegistry(); final CountDownLatch lock = new CountDownLatch(1); final AbstractBackgroundAction action = new AbstractBackgroundAction() { @Override public Object run() { return null; } @Override public void finish() { super.finish(); lock.countDown(); } }; assertTrue(r.add(action)); action.finish(); lock.await(1, TimeUnit.SECONDS); r.remove(action); assertFalse(r.contains(action)); assertNull(r.getCurrent()); }
public synchronized BackgroundAction getCurrent() { final Iterator<BackgroundAction> iter = running.iterator(); if(iter.hasNext()) { return iter.next(); } return null; }
BackgroundActionRegistry extends Collection<BackgroundAction> implements BackgroundActionListener { public synchronized BackgroundAction getCurrent() { final Iterator<BackgroundAction> iter = running.iterator(); if(iter.hasNext()) { return iter.next(); } return null; } }
BackgroundActionRegistry extends Collection<BackgroundAction> implements BackgroundActionListener { public synchronized BackgroundAction getCurrent() { final Iterator<BackgroundAction> iter = running.iterator(); if(iter.hasNext()) { return iter.next(); } return null; } BackgroundActionRegistry(); }
BackgroundActionRegistry extends Collection<BackgroundAction> implements BackgroundActionListener { public synchronized BackgroundAction getCurrent() { final Iterator<BackgroundAction> iter = running.iterator(); if(iter.hasNext()) { return iter.next(); } return null; } BackgroundActionRegistry(); static BackgroundActionRegistry global(); synchronized BackgroundAction getCurrent(); @Override synchronized void start(final BackgroundAction action); @Override synchronized void stop(final BackgroundAction action); @Override synchronized void cancel(final BackgroundAction action); @Override synchronized boolean add(final BackgroundAction action); @Override synchronized boolean remove(final Object action); @Override boolean equals(final Object o); @Override int hashCode(); }
BackgroundActionRegistry extends Collection<BackgroundAction> implements BackgroundActionListener { public synchronized BackgroundAction getCurrent() { final Iterator<BackgroundAction> iter = running.iterator(); if(iter.hasNext()) { return iter.next(); } return null; } BackgroundActionRegistry(); static BackgroundActionRegistry global(); synchronized BackgroundAction getCurrent(); @Override synchronized void start(final BackgroundAction action); @Override synchronized void stop(final BackgroundAction action); @Override synchronized void cancel(final BackgroundAction action); @Override synchronized boolean add(final BackgroundAction action); @Override synchronized boolean remove(final Object action); @Override boolean equals(final Object o); @Override int hashCode();  }