您的位置:首页 > 房产 > 建筑 > 电销管理系统哪个好用_全国软件公司排名_google开户_企业营销推广

电销管理系统哪个好用_全国软件公司排名_google开户_企业营销推广

2024/10/7 10:17:36 来源:https://blog.csdn.net/qq_36608622/article/details/142591795  浏览:    关键词:电销管理系统哪个好用_全国软件公司排名_google开户_企业营销推广
电销管理系统哪个好用_全国软件公司排名_google开户_企业营销推广

StopWath是 apache commons lang3 包下的一个任务执行时间监视器,与我们平时常用的秒表的行为比较类似,我们先看一下其中的一些重要方法:

图片

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>    <groupId>org.apache.commons</groupId>    <artifactId>commons-lang3</artifactId>    <version>3.6</version>
</dependency>

Apache提供的这个任务执行监视器功能丰富强大,灵活性强,如下经典实用案例:

public static void main(String[] args) throws InterruptedException {    //创建后立即start,常用    StopWatch watch = StopWatch.createStarted();// StopWatch watch = new StopWatch();    // watch.start();    Thread.sleep(1000);    System.out.println(watch.getTime());    System.out.println("统计从开始到现在运行时间:" + watch.getTime() + "ms");Thread.sleep(1000);    watch.split();    System.out.println("从start到此刻为止的时间:" + watch.getTime());   System.out.println("从开始到第一个切入点运行时间:" + watch.getSplitTime());Thread.sleep(1000);    watch.split();    System.out.println("从开始到第二个切入点运行时间:" + watch.getSplitTime());    // 复位后, 重新计时    watch.reset();    watch.start();    Thread.sleep(1000);    System.out.println("重新开始后到当前运行时间是:" + watch.getTime());    // 暂停 与 恢复    watch.suspend();    System.out.println("暂停2秒钟");    Thread.sleep(2000);    // 上面suspend,这里要想重新统计,需要恢复一下   watch.resume();    System.out.println("恢复后执行的时间是:" + watch.getTime());Thread.sleep(1000);    watch.stop();System.out.println("花费的时间》》" + watch.getTime() + "ms");    // 直接转成s    System.out.println("花费的时间》》" + watch.getTime(TimeUnit.SECONDS) + "s");
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com