/** * Adds a new listener of the given type to this list. * * @param t the type of the listener. * @param l the listener. * @param <T> the type of the listener, must be a subclass of {@code java.util.EventListener}. */ public <T extends EventListener> void add( final Class<T> t, final T l ) { lock.writeLock().lock(); try { ensureCapacity( size + 2 ); data[ size ] = t; data[ size + 1 ] = new WeakReference( l ); size += 2; } finally { lock.writeLock().unlock(); } }