打字猴:1.700475224e+09
1700475224 public static SignInfo getSignInfo(ExtrinsicState key){
1700475225
1700475226 //设置返回对象
1700475227
1700475228 SignInfo result=null;
1700475229
1700475230 //池中没有该对象,则建立,并放入池中
1700475231
1700475232 if(!pool.containsKey(key)){
1700475233
1700475234 result=new SignInfo();
1700475235
1700475236 pool.put(key,result);
1700475237
1700475238 }else{
1700475239
1700475240 result=pool.get(key);
1700475241
1700475242 }
1700475243
1700475244 return result;
1700475245
1700475246 }
1700475247
1700475248 }
1700475249
1700475250 重点是看看我们的场景类,我们来测试一下性能差异,如代码清单28-15所示。
1700475251
1700475252 代码清单28-15 场景类
1700475253
1700475254 public class Client{
1700475255
1700475256 public static void main(String[]args){
1700475257
1700475258 //初始化对象池
1700475259
1700475260 ExtrinsicState state1=new ExtrinsicState();
1700475261
1700475262 state1.setSubject(“科目1”);
1700475263
1700475264 state1.setLocation(“上海”);
1700475265
1700475266 SignInfoFactory.getSignInfo(state1);
1700475267
1700475268 ExtrinsicState state2=new ExtrinsicState();
1700475269
1700475270 state2.setSubject(“科目1”);
1700475271
1700475272 state2.setLocation(“上海”);
1700475273
[ 上一页 ]  [ :1.700475224e+09 ]  [ 下一页 ]