01: // $Id: Sample2.java,v 1.2 2004/02/06 23:06:27 vauclair Exp $
02:
03: package ejp;
04:
05: public class Sample2 {
06: private static void work1() {
07: long start = System.currentTimeMillis();
08: a();
09: for (long l = 0; l <= 1500; l = System.currentTimeMillis()
10: - start)
11: ;
12: a();
13: System.out.println("work1: "
14: + (System.currentTimeMillis() - start) + " ms");
15: }
16:
17: private static void a() {
18: int i = 0;
19: i *= ++i;
20: }
21:
22: private static void work2() {
23: long start = System.currentTimeMillis();
24: a();
25: for (long l = 0; l <= 15000000 * 8; l++)
26: ;
27: a();
28: System.out.println("work2: "
29: + (System.currentTimeMillis() - start) + " ms");
30: }
31:
32: public static void main(String[] args_) throws Exception {
33: System.out.println("Sleeping...");
34: Thread.sleep(1234);
35: System.out.println("Done.");
36:
37: System.out.println("Working (1)...");
38: work1();
39: System.out.println("Done.");
40:
41: System.out.println("Working (2)...");
42: work2();
43: System.out.println("Done.");
44: }
45: }
|