Example usage for java.lang InheritableThreadLocal InheritableThreadLocal

List of usage examples for java.lang InheritableThreadLocal InheritableThreadLocal

Introduction

In this page you can find the example usage for java.lang InheritableThreadLocal InheritableThreadLocal.

Prototype

InheritableThreadLocal

Source Link

Usage

From source file:com.agapple.asyncload.impl.pool.AsyncLoadThreadPool.java

@Override
public void execute(Runnable command) {
    if (command instanceof AsyncLoadFuture) {
        AsyncLoadFuture afuture = (AsyncLoadFuture) command;
        boolean flag = afuture.getConfig().getNeedThreadLocalSupport();
        if (flag) {
            Thread thread = Thread.currentThread();
            if (ReflectionUtils.getField(threadLocalField, thread) == null) {
                // ThreadLocal,
                new ThreadLocal<Boolean>(); // runnerThreadLocalMap
            }//from   w  w  w  . j  av a 2s  .c om
            if (ReflectionUtils.getField(inheritableThreadLocalField, thread) == null) {
                // ThreadLocal,
                new InheritableThreadLocal<Boolean>(); // ?ThreadLocal
            }
        }
    }

    super.execute(command);// ??
}

From source file:org.apache.jmeter.protocol.http.control.CacheManager.java

private void clearCache() {
    log.debug("Clear cache");
    threadCache = new InheritableThreadLocal<Map<String, CacheEntry>>() {
        @Override/*from   w  w  w . j av  a2  s .c o m*/
        protected Map<String, CacheEntry> initialValue() {
            // Bug 51942 - this map may be used from multiple threads
            @SuppressWarnings("unchecked") // LRUMap is not generic currently
            Map<String, CacheEntry> map = new LRUMap(getMaxSize());
            return Collections.<String, CacheEntry>synchronizedMap(map);
        }
    };
}