ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/Fib.java
(Generate patch)

Comparing jsr166/src/test/loops/Fib.java (file contents):
Revision 1.6 by jsr166, Wed Jul 4 20:07:01 2012 UTC vs.
Revision 1.9 by jsr166, Sat Sep 12 18:59:49 2015 UTC

# Line 39 | Line 39 | public final class Fib extends Recursive
39          }
40  
41          for (int reps = 0; reps < 2; ++reps) {
42 <            ForkJoinPool g = (procs == 0) ? new ForkJoinPool() :
42 >            ForkJoinPool g = (procs == 0) ? ForkJoinPool.commonPool() :
43                  new ForkJoinPool(procs);
44              lastStealCount = g.getStealCount();
45              for (int i = 0; i < 20; ++i) {
# Line 48 | Line 48 | public final class Fib extends Recursive
48                  //                    Thread.sleep(100);
49              }
50              System.out.println(g);
51 <            g.shutdown();
52 <            if (!g.awaitTermination(10, TimeUnit.SECONDS))
53 <                throw new Error();
54 <            g = null;
51 >            if (g != ForkJoinPool.commonPool())
52 >                g.shutdown();
53              Thread.sleep(500);
54          }
55      }
56  
59
57      /** for time conversion */
58      static final long NPS = (1000L * 1000 * 1000);
59  
60      static void test(ForkJoinPool g, int num) throws Exception {
61          int ps = g.getParallelism();
65        //        g.setParallelism(ps);
62          long start = System.nanoTime();
63          Fib f = new Fib(num);
64          g.invoke(f);
# Line 80 | Line 76 | public final class Fib extends Recursive
76          System.out.println();
77      }
78  
83
79      // Initialized with argument; replaced with result
80      int number;
81  
# Line 98 | Line 93 | public final class Fib extends Recursive
93              else {
94                  Fib f1 = new Fib(n - 1);
95                  Fib f2 = new Fib(n - 2);
101                //                forkJoin(f1, f2);
96                  invokeAll(f1, f2);
97                  number = f1.number + f2.number;
98              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines