在类定义之后添加以下实例变量,如清单1所示。
Add the following instance variables right after the class definition as shown in listing 1.
相反地,人们通过给Thread添加一个实例变量(该变量用于保存当前线程的从线程局部变量到它的值的映射的HashMap)来修改thread类以支持ThreadLocal。
Instead, the thread class was modified to support ThreadLocal by adding an instance variable to thread that holds a HashMap mapping thread-local variables to their values for the current thread.
应用推荐