Code Fragment-用户可配置+系统默认可行

来源:互联网 发布:ubuntu无法复制粘贴 编辑:程序博客网 时间:2024/05/16 08:08

实现一个功能,为用户提供一个基础的版本。额外的想法,添加用户可以配置的支持。

优点:

  1. 使用默认版本:用户可以在最简单的情况下,使用代码,运行良好。
  2. 用户自己配置:提供了更多的选择,这是重用的一种策略。
还是在Integer的源代码中,默认的Cache大小是

int h = 127;

可选的处理:(从配置文件中读取)

String integerCacheHighPropValue = sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");if (integerCacheHighPropValue != null) {int i = parseInt(integerCacheHighPropValue);i = Math.max(i, 127);// Maximum array size is Integer.MAX_VALUEh = Math.min(i, Integer.MAX_VALUE - (-low));}high = h;

原创粉丝点击