diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap.java index 4d268ea8614ccc..c7273d5ccd3428 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap.java @@ -9,13 +9,18 @@ import javax.annotation.Nullable; -import android.support.v4.util.Pools; +import android.support.v4.util.Pools.SimplePool; /** * Implementation of Dynamic wrapping a ReadableMap. */ public class DynamicFromMap implements Dynamic { - private static final Pools.SimplePool sPool = new Pools.SimplePool<>(10); + private static final ThreadLocal> sPool = new ThreadLocal>() { + @Override + protected SimplePool initialValue() { + return new SimplePool<>(10); + } + }; private @Nullable ReadableMap mMap; private @Nullable String mName; @@ -24,7 +29,7 @@ public class DynamicFromMap implements Dynamic { private DynamicFromMap() {} public static DynamicFromMap create(ReadableMap map, String name) { - DynamicFromMap dynamic = sPool.acquire(); + DynamicFromMap dynamic = sPool.get().acquire(); if (dynamic == null) { dynamic = new DynamicFromMap(); } @@ -37,7 +42,7 @@ public static DynamicFromMap create(ReadableMap map, String name) { public void recycle() { mMap = null; mName = null; - sPool.release(this); + sPool.get().release(this); } @Override