闲着无聊之StopWatch

从此弃用时间戳相减的方式来计算运行时间。 

import org.apache.commons.lang.time.StopWatch;
import org.junit.Test;

public class Test1 {
	@Test
	public void test_StopWatch() throws InterruptedException
	{
		
		
		StopWatch stopWatch = new StopWatch();
		stopWatch.start();
		//Thread.sleep(1000);
		for(int i=0;i<1000;i++)
		{
			Thread.sleep(1);
		}
		stopWatch.stop();
		System.out.println(stopWatch.getTime());
		//System.out.println(sw.toString());
	}
}

...

你可能感兴趣的:(lang,commons,stopwatch)