Through this new "Parallel Infrastructure" new parallel algorithms could be implemented very simple. This framework provides simple parallel patterns for task parallel programming:
Parallel
provides for each parallel pattern a simple interface.
Parallel.For(new BlockedRange1D(0, 10, 1), new PForTask() {
public void execute(BlockedRange range) {
for(int i = range.start(); i < range.end(); i++) { System.out.println(i); }
}});
PForJob
. The body implements a class that extends PForTask
. The number
of iterations is given by a BlockedRange
(1- and 2-dimensional). The BlockedRange
has three (1D) or six (2D)
parameter. These parameters define a start and a end value of the for loops. The programmer could also define a grain size for each task.
PReduceJob
returns with an aggregated result of all tasks. A class
which extends the PReduceTask
has override the reduce
method.