/** {@inheritDoc} */ public <A> void addShutdownListener(final EventListener<A> shutdownListener, final A attachment) { synchronized (this) { final Registration<A> reg = new Registration<A>(shutdownListener, attachment); if (list == null) { reg.run(); } else { list.add(reg); } } }
/** * Run and remove all registered listeners, and mark this object as having been shut down so that * future listeners are invoked immediately. */ public void shutdown() { final List<Registration<?>> list; synchronized (this) { list = this.list; this.list = null; } if (list != null) { for (Registration<?> registration : list) { registration.run(); } } }
/** * Run and remove all registered listeners, and mark this object as having been shut down so that * future listeners are invoked immediately. */ public void shutdown() { final List<Registration<?>> list; synchronized (this) { list = this.list; this.list = null; } if (list != null) { for (Registration<?> registration : list) { registration.run(); } } }
/** {@inheritDoc} */ public <A> void addShutdownListener(final EventListener<A> shutdownListener, final A attachment) { synchronized (this) { final Registration<A> reg = new Registration<A>(shutdownListener, attachment); if (list == null) { reg.run(); } else { list.add(reg); } } }
/** {@inheritDoc} */ public <A> void addShutdownListener(final EventListener<A> shutdownListener, final A attachment) { synchronized (this) { final Registration<A> reg = new Registration<A>(shutdownListener, attachment); if (list == null) { reg.run(); } else { list.add(reg); } } }
/** * Run and remove all registered listeners, and mark this object as having been shut down so that * future listeners are invoked immediately. */ public void shutdown() { final List<Registration<?>> list; synchronized (this) { list = this.list; this.list = null; } if (list != null) { for (Registration<?> registration : list) { registration.run(); } } }