Pools.SynchronizedPool

public class Pools.SynchronizedPool<T> extends Pools.SimplePool implements Pools.Pool


Synchronized) pool of objects.

Parameters
<T>

The pooled type.

Summary

Public constructors

SynchronizedPool(int maxPoolSize)

Creates a new instance.

Public methods

@Override T
@Override boolean
release(@NonNull T instance)

Release an instance to the pool.

Public constructors

SynchronizedPool

public SynchronizedPool(int maxPoolSize)

Creates a new instance.

Parameters
int maxPoolSize

The max pool size.

Throws
java.lang.IllegalArgumentException

If the max pool size is less than zero.

Public methods

acquire

@Override
public T acquire()
Returns
T

An instance from the pool if such, null otherwise.

release

@Override
public boolean release(@NonNull T instance)

Release an instance to the pool.

Parameters
@NonNull T instance

The instance to release.

Returns
boolean

Whether the instance was put in the pool.

Throws
java.lang.IllegalStateException

If the instance is already in the pool.