ι 版权声明:本文为博主原创文章,未经博主允许不得转载。
先看Android源码(API24)中对ThreadLocal的定义:
public class ThreadLocal<T>
即ThreadLoca是一个泛型类,再看对该类的注释:
/** * This class provides thread-local variables. These variables differ from * their normal counterparts in that each thread that accesses one (via its * <tt>get</tt> or <tt>set</tt> method) has its own, independently initialized * copy of the variable. <tt>ThreadLocal</tt> instances are typically private * static