文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 初中教育 > 英语 > 初二英语 > 周 祥,北邮-从虚拟机视角谈 Java 应用性能优化-lo-jvm-perf_index
侵权投诉

周 祥,北邮-从虚拟机视角谈 Java 应用性能优化-lo-jvm-perf_index

周 祥,北邮-从虚拟机视角谈 Java 应用性

public class ObjectFactory {

/** A counter for counting the number of objects in use. */

private static int objInUse = 0;

/** A counter for counting the number of objects in pool. */

private static int objInPool = 0;

/** The object pool. */

private static HashMap objectPool = new HashMap();

/** The corresponding object pool for a specific class. */

private static LinkedHashSet subObjPool;

/** Generate object for use */

public synchronized static Object generate(String className) {

Object retObj = null;

subObjPool = (LinkedHashSet) objectPool.get(className);

if (subObjPool != null && subObjPool.size() < 0) {

retObj = subObjPool.iterator().next();

subObjPool.remove(retObj);

objInPool--;

} else {

try {

retObj = newObj(className);

} catch (InstantiationException ie) {

return null;

} catch (IllegalAccessException iae) {

return null;

} catch (ClassNotFoundException cnfe) {

return null;

}

}

objInUse++;

return retObj;

}

public synchronized static void drop(Object freeObject) {

if (freeObject != null) {

subObjPool = (LinkedHashSet) objectPool.get(className);

if (subObjPool == null) {

subObjPool = new LinkedHashSet(); objectPool.put(className, subObjPool);

上一页第7页

你可能喜欢

  • Java虚拟机
  • Java语言
  • JAVA程序
  • 语言规范
  • 内存分配
  • SQL语句优化
  • 性能调优

热门文档

相关文档

  • 01-Java初览-20120928

    为了应用于消费类电子设备的开发; 1994年Internet开始起步,1995年NetScape宣布把 1994年Internet开始起步 1995年NetScape宣布把 Java集成到其浏览器中,可执行的Java...

  • 01-Java初览-20120928

    为了应用于消费类电子设备的开发; 1994年Internet开始起步,1995年NetScape宣布把 1994年Internet开始起步 1995年NetScape宣布把 Java集成到其浏览器中,可执行的Java...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email