// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.concurrent.ForkJoinPool;

public class PA17 {
    private static ForkJoinPool fjp = new ForkJoinPool(8);
    public static void addOneToAll(Integer[] a) {
        ParallelArray<Integer> pa = new ParallelArray<>(fjp, a);
        pa.apply(new Applier<Integer>() {
            public void applyToElement(Integer[] a, int ix) {
                a[ix] = a[ix] + 1;
            }
        });
    }
    public static void main(String[] args) {
        Integer[] a = new Integer[1000];
        for(int i = 0; i < a.length; i++) {
            a[i] = i + 1;
        }
        addOneToAll(a);
        System.out.println(a[0] + " " + a[a.length - 1]);
    }
}
