The Android Developer Challenge is back! Submit your idea before December 2.

Pools

class Pools
kotlin.Any
   ↳ androidx.core.util.Pools

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

public class MyPooledClass {
 
      private static final SynchronizedPool<mypooledclass>
  sPool =
              new SynchronizedPool
 <mypooledclass>
  (10); public static MyPooledClass obtain() { MyPooledClass instance = sPool.acquire(); return (instance != null) ? instance : new MyPooledClass(); } public void recycle() { // Clear state if needed. sPool.release(this); } . . . } 
 </mypooledclass>
</mypooledclass>

Summary

Nested classes

abstract

Interface for managing a pool of objects.

Simple (non-synchronized) pool of objects.

Synchronized) pool of objects.