类 SystemClock


  • public class SystemClock
    extends java.lang.Object
    高并发场景下System.currentTimeMillis()的性能问题的优化

    System.currentTimeMillis()的调用比new一个普通对象要耗时的多(具体耗时高出多少我还没测试过,有人说是100倍左右)

    System.currentTimeMillis()之所以慢是因为去跟系统打了一次交道

    后台定时更新时钟,JVM退出时,线程自动回收

    10亿:43410,206,210.72815533980582%

    1亿:4699,29,162.0344827586207%

    1000万:480,12,40.0%

    100万:50,10,5.0%

    从以下版本开始:
    2016-08-01
    作者:
    hubin
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static long now()  
      static java.lang.String nowDate()  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 方法详细资料

      • now

        public static long now()
      • nowDate

        public static java.lang.String nowDate()