# Pools

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/Pools.kt+class:androidx.core.util.Pools) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
class Pools
```

<br />

*** ** * ** ***

Helper class for creating pools of objects. An example use looks like this:

```kotlin
class MyPooledClass {

    fun recycle() {
        // Clear state if needed, then return this instance to the Pool
        pool.release(this)
    }

    companion object {
        private val pool = Pools.SynchronizedPool<MyPooledClass>(10)

        fun obtain() : MyPooledClass {
            // Get an instance from the Pool or
            // construct a new one if none are available
            return pool.acquire() ?: MyPooledClass()
        }
    }
}
```

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/core/util/Pools.Pool<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` Interface for managing a pool of objects. |
| `open class https://developer.android.com/reference/kotlin/androidx/core/util/Pools.SimplePool<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/core/util/Pools.Pool<T>` Simple (non-synchronized) pool of objects. |
| `open class https://developer.android.com/reference/kotlin/androidx/core/util/Pools.SynchronizedPool<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> : https://developer.android.com/reference/kotlin/androidx/core/util/Pools.SimplePool<T>` Synchronized pool of objects. |