Class FastThreadLocal<T>

java.lang.Object
org.glowroot.agent.plugin.api.util.FastThreadLocal<T>

public class FastThreadLocal<T> extends Object
Wrapper that implements optimized ThreadLocal access pattern ideal for heavily used ThreadLocals. It is faster to use a mutable holder object and always perform ThreadLocal.get() and never use ThreadLocal.set(), because the value is more likely to be found in the ThreadLocalMap direct hash slot and avoid the slow path ThreadLocalMap.getEntryAfterMiss(). Important: this thread local will live in ThreadLocalMap forever, so use with care.
  • Constructor Details

    • FastThreadLocal

      public FastThreadLocal()
  • Method Details

    • get

      public T get()
    • set

      public void set(T value)
    • getHolder

      public FastThreadLocal.Holder<T> getHolder()
    • initialValue

      protected T initialValue()