StopWath,apache commons lang3 包下的一个任务执行时间监视器的使用
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");
}