| Author |
Error when using new ForkJoin feature
|
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 819
|
|
Hi, I was experimenting with the new Fork/Join "task stealing" feature described at http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/RecursiveAction.html
Here is my implementation of the IncremementTask from that page:
This code generates the following error and I don't understand why:
beyond that, how can a programmer begin to estimate the thresholds that would be reasonable for breaking off tasks in this way?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
You're creating a RecursiveAction but it looks like you're not really using the fork-join framework.
You have to create a ForkJoinPool and let it execute your tasks, in line 12 of main(), instead of calling compute() directly.
Here's an example.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 819
|
|
Thank you . I changed my main method to look like this and it works:
|
 |
 |
|
|
subject: Error when using new ForkJoin feature
|
|
|