@Test public void testRecyclable() { long maxCycles = 1000; Recyclable<Object> r = new Recyclable<>(Object::new, maxCycles); Object o = r.get(); for (int i=0; i < maxCycles; i++) { assertEquals(o, r.get(), "i=" + i); } assertNotEquals(o, r.get()); }
public Recyclable(Supplier<T> supplier, long maxCycles) { this.supplier = supplier; this.maxCycles = maxCycles; }
Recyclable implements Supplier<T> { public Recyclable(Supplier<T> supplier, long maxCycles) { this.supplier = supplier; this.maxCycles = maxCycles; } }
Recyclable implements Supplier<T> { public Recyclable(Supplier<T> supplier, long maxCycles) { this.supplier = supplier; this.maxCycles = maxCycles; } Recyclable(Supplier<T> supplier, long maxCycles); }
Recyclable implements Supplier<T> { public Recyclable(Supplier<T> supplier, long maxCycles) { this.supplier = supplier; this.maxCycles = maxCycles; } Recyclable(Supplier<T> supplier, long maxCycles); @Override T get(); }
Recyclable implements Supplier<T> { public Recyclable(Supplier<T> supplier, long maxCycles) { this.supplier = supplier; this.maxCycles = maxCycles; } Recyclable(Supplier<T> supplier, long maxCycles); @Override T get();  }