FJTaskRunnerGroup.interruptAll
when you are done using one-shot groups. Otherwise, because FJTaskRunners set Thread.isDaemon
status, they will not normally be reclaimed until program termination. The main supported methods are execute
, which starts a task processed by FJTaskRunner threads, and invoke
, which starts one and waits for completion. For example, you might extend the above FJTasks
class to support a task-based computation, say, the Fib
class from the FJTask
documentation:
class Tasks { // continued // ... static int fib(int n) { try { Fib f = new Fib(n); group.invoke(f); return f.getAnswer(); } catch (InterruptedException ex) { throw new Error("Interrupted during computation"); } } }
Method stats()
can be used to monitor performance. Both FJTaskRunnerGroup and FJTaskRunner may be compiled with the compile-time constant COLLECT_STATS set to false. In this case, various simple counts reported in stats() are not collected. On platforms tested, this leads to such a tiny performance improvement that there is very little motivation to bother.
[ Introduction to this package. ]
@see FJTask @see FJTaskRunner
|
|
|
|