52 |
|
* public Solver(float[][] matrix) { |
53 |
|
* data = matrix; |
54 |
|
* N = matrix.length; |
55 |
< |
* barrier = new CyclicBarrier(N, |
56 |
< |
* new Runnable() { |
57 |
< |
* public void run() { |
58 |
< |
* mergeRows(...); |
59 |
< |
* } |
60 |
< |
* }); |
61 |
< |
* for (int i = 0; i < N; ++i) |
62 |
< |
* new Thread(new Worker(i)).start(); |
55 |
> |
* Runnable barrierAction = |
56 |
> |
* new Runnable() { public void run() { mergeRows(...); }}; |
57 |
> |
* barrier = new CyclicBarrier(N, barrierAction); |
58 |
|
* |
59 |
< |
* waitUntilDone(); |
59 |
> |
* List<Thread> threads = new ArrayList<Thread>(N); |
60 |
> |
* for (int i = 0; i < N; i++) { |
61 |
> |
* Thread thread = new Thread(new Worker(i)); |
62 |
> |
* threads.add(thread); |
63 |
> |
* thread.start(); |
64 |
> |
* } |
65 |
> |
* |
66 |
> |
* // wait until done |
67 |
> |
* for (Thread thread : threads) |
68 |
> |
* thread.join(); |
69 |
|
* } |
70 |
|
* }}</pre> |
71 |
|
* |