@Test public void testCreateMoreThanMaxCapacity() { final BlockingQueuePool<AtomicBoolean> pool = new BlockingQueuePool<>(10, AtomicBoolean::new, AtomicBoolean::get, DO_NOTHING); for (int i = 0; i < 50; i++) { final AtomicBoolean value = pool.borrowObject(); assertNotNull(value); } }
@Override public T borrowObject() { final T existing = queue.poll(); if (existing != null) { return existing; } return creationFunction.get(); }
BlockingQueuePool implements ObjectPool<T> { @Override public T borrowObject() { final T existing = queue.poll(); if (existing != null) { return existing; } return creationFunction.get(); } }
BlockingQueuePool implements ObjectPool<T> { @Override public T borrowObject() { final T existing = queue.poll(); if (existing != null) { return existing; } return creationFunction.get(); } BlockingQueuePool(final int maxSize, final Supplier<T> creationFunction, final Predicate<T> reuseCheck, final Consumer<T> returnPreparation); }
BlockingQueuePool implements ObjectPool<T> { @Override public T borrowObject() { final T existing = queue.poll(); if (existing != null) { return existing; } return creationFunction.get(); } BlockingQueuePool(final int maxSize, final Supplier<T> creationFunction, final Predicate<T> reuseCheck, final Consumer<T> returnPreparation); @Override T borrowObject(); @Override void returnObject(final T somethingBorrowed); }
BlockingQueuePool implements ObjectPool<T> { @Override public T borrowObject() { final T existing = queue.poll(); if (existing != null) { return existing; } return creationFunction.get(); } BlockingQueuePool(final int maxSize, final Supplier<T> creationFunction, final Predicate<T> reuseCheck, final Consumer<T> returnPreparation); @Override T borrowObject(); @Override void returnObject(final T somethingBorrowed);  }