class MyThreadScopeData {// 單例private MyThreadScopeData() {}// 提供獲取實例方法public static synchronized MyThreadScopeData getThreadInstance() {// 從當前線程範圍內數據集中獲取實例對象MyThreadScopeData instance = map.get();if ( instance == null) {instance = new MyThreadScopeData();map.set(instance);}return instance;}// 將實例對象存入當前線程範圍內數據集中private static MyThreadScopeData instance = null; // 飢餓模式private String name;private int age;public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) { this.age = age;}}