### Question:
TimedCounterList extends AbstractList<T> { public void cleanup( long maxage ) { m_lock.writeLock().lock(); try { long now = System.currentTimeMillis(); for( Iterator<CounterItem<T>> i = m_list.iterator(); i.hasNext(); ) { CounterItem<T> ci = i.next(); long age = now - ci.m_addTime; if( age > maxage ) { i.remove(); } } } finally { m_lock.writeLock().unlock(); } }  @Override T set( int index, T element ); @Override T get( int index ); @Override int size(); @Override void add( int index, T element ); @Override T remove( int index ); int count( T obj ); void cleanup( long maxage ); long getAddTime( int index );  }### Answer:
@Test public void testCleanup() { try { Thread.sleep(110); m_list.cleanup(100); Assertions.assertEquals( 0, m_list.count( "Foo" ), "Foo" ); Assertions.assertEquals( 0, m_list.count( "Foo" ), "Bar" ); Assertions.assertEquals( 0, m_list.count( "Foo" ), "Baz" ); Assertions.assertEquals( 0, m_list.size(), "size" ); } catch( InterruptedException e ) { e.printStackTrace(); } }