背景: 最近在项目用到了ThreadLocal,存放一些值.起线程异步获取ThreadLocal中的值,得到null.这是由于,ThreadLocal.get()会获取当前线程的一个map对象,以ThreadLocal为key获取对象. demo: 这里定义了一个Person类,使用两个线程,一个向threadlocal set(),两个线程都使用threadLocal.get()获取存放的对象 其中一个线程没有获取到值 /** * Created by GuanXF on 2017/12/8.
我写这个工具,主要是多次在将自己的代码和别人代码做对比时,不想繁琐地用眼看他设置的和自己设置的哪里不一样. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Properties { class Properties { /// <summary> /// 通过类型和对象获取对象键-值的字典集合. /// </summary> /// <