当前位置:网站首页>long start = currentTimeMillis();

long start = currentTimeMillis();

2022-06-22 05:16:00 a good idea

package currentTimeMillis;
import java.util.Random;

import static java.lang.System.currentTimeMillis;
import static java.lang.Thread.sleep;
public class TaskMethodProvider {

	
	
	 private static Random random = new Random();

	    public void taskOne() throws Exception {
	        System.out.println(" Start task one ");
	        long start = currentTimeMillis();
	        sleep(random.nextInt(10000));
	        long end = currentTimeMillis();
	        System.out.println(" Complete task one , Time consuming :" + (end - start) + " millisecond ");
	    }

	    public void taskTwo() throws Exception {
	        System.out.println(" Start task two ");
	        long start = currentTimeMillis();
	        sleep(random.nextInt(10000));
	        long end = currentTimeMillis();
	        System.out.println(" Finish task two , Time consuming :" + (end - start) + " millisecond ");
	    }

	    public void taskThree() throws Exception {
	        System.out.println(" Start task three ");
	        long start = currentTimeMillis();
	        sleep(random.nextInt(10000));
	        long end = currentTimeMillis();
	        System.out.println(" Complete task three , Time consuming :" + (end - start) + " millisecond ");
	    }
}

原网站

版权声明
本文为[a good idea]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220510552568.html