Pool { public T free(T element) { final T result = element.getNext(); element.setNext(free); free = element; return result; }  synchronized T allocate(); T free(T element); boolean isEmpty(); int size();  }
@SuppressWarnings("boxing") @Test public void testFree() { ListNode<Integer> node = new ListNode<>(); node.setKey(-8); pool.free(node); assertSame(node, pool.allocate()); assertEquals(-8, node.getKey().intValue()); }