Pools.SynchronizedPool

Added in 1.1.0

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


Synchronized) pool of objects.

Parameters
<T>

The pooled type.

Summary

Public constructors

SynchronizedPool(int maxPoolSize)

Creates a new instance.

Public methods

T
boolean
release(@NonNull T instance)

Release an instance to the pool.

Public constructors

SynchronizedPool

Added in 1.1.0
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

public T acquire()
Returns
T

An instance from the pool if such, null otherwise.

release

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.