@Test public void parallelRunFunction() { final Function1<Integer, Double> function1 = new Function1<Integer, Double>() { @Override public Double execute(Integer x) { for (int i = LowerBound; i < UpperBound; i++) { Hero.findRoot(i); } if (log.isDebugEnabled()) log.debug("FindRoot({}) returns [{}]", UpperBound, Hero.findRoot(UpperBound)); return Hero.findRoot(UpperBound); } }; @Cleanup AutoStopwatch stopwatch = new AutoStopwatch(); List<Double> results = Parallels.run(0, 100, function1); Assert.assertNotNull(results); Assert.assertEquals(100, results.size()); }
public static void run(int count, final Runnable runnable) { run(0, count, runnable); }
Parallels { public static void run(int count, final Runnable runnable) { run(0, count, runnable); } }
Parallels { public static void run(int count, final Runnable runnable) { run(0, count, runnable); } private  Parallels(); }
Parallels { public static void run(int count, final Runnable runnable) { run(0, count, runnable); } private  Parallels(); static ExecutorService createExecutor(); static ExecutorService createExecutor(int threadCount); static void run(int count, final Runnable runnable); static void run(int fromInclude, int toExclude, final Runnable action); static void run(int fromInclude, int toExclude, int step, final Runnable runnable); static void run(int count, final Action1<Integer> action); static void run(int fromInclude, int toExclude, final Action1<Integer> action); static void run(int fromInclude, int toExclude, int step, final Action1<Integer> action); static List<V> run(int count, final Callable<V> callable); static List<V> run(int fromInclude, int toExclude, final Callable<V> callable); static List<V> run(int fromInclude, int toExclude, int step, final Callable<V> callable); static List<V> run(int count, final Function1<Integer, V> function); static List<V> run(int fromInclude, int toExclude, final Function1<Integer, V> function); static List<V> run(int fromInclude, int toExclude, int step, final Function1<Integer, V> function); static void runEach(final Iterable<T> elements, final Action1<T> action); static List<V> runEach(final Iterable<T> elements, final Function1<T, V> function); static void runPartitions(int count, final Action1<List<Integer>> action); static void runPartitions(int fromInclude, int toExclude, final Action1<List<Integer>> action); static void runPartitions(int fromInclude, int toExclude, int step, final Action1<List<Integer>> action); static List<V> runPartitions(int count, final Function1<List<Integer>, List<V>> function); static List<V> runPartitions(int fromInclude, int toExclude, final Function1<List<Integer>, List<V>> function); static List<V> runPartitions(int fromInclude, int toExclude, int step, final Function1<List<Integer>, List<V>> function); static void runPartitions(final Iterable<T> elements, final Action1<List<T>> action); static List<V> runPartitions(final Iterable<T> elements, final Function1<List<T>, List<V>> function); }
Parallels { public static void run(int count, final Runnable runnable) { run(0, count, runnable); } private  Parallels(); static ExecutorService createExecutor(); static ExecutorService createExecutor(int threadCount); static void run(int count, final Runnable runnable); static void run(int fromInclude, int toExclude, final Runnable action); static void run(int fromInclude, int toExclude, int step, final Runnable runnable); static void run(int count, final Action1<Integer> action); static void run(int fromInclude, int toExclude, final Action1<Integer> action); static void run(int fromInclude, int toExclude, int step, final Action1<Integer> action); static List<V> run(int count, final Callable<V> callable); static List<V> run(int fromInclude, int toExclude, final Callable<V> callable); static List<V> run(int fromInclude, int toExclude, int step, final Callable<V> callable); static List<V> run(int count, final Function1<Integer, V> function); static List<V> run(int fromInclude, int toExclude, final Function1<Integer, V> function); static List<V> run(int fromInclude, int toExclude, int step, final Function1<Integer, V> function); static void runEach(final Iterable<T> elements, final Action1<T> action); static List<V> runEach(final Iterable<T> elements, final Function1<T, V> function); static void runPartitions(int count, final Action1<List<Integer>> action); static void runPartitions(int fromInclude, int toExclude, final Action1<List<Integer>> action); static void runPartitions(int fromInclude, int toExclude, int step, final Action1<List<Integer>> action); static List<V> runPartitions(int count, final Function1<List<Integer>, List<V>> function); static List<V> runPartitions(int fromInclude, int toExclude, final Function1<List<Integer>, List<V>> function); static List<V> runPartitions(int fromInclude, int toExclude, int step, final Function1<List<Integer>, List<V>> function); static void runPartitions(final Iterable<T> elements, final Action1<List<T>> action); static List<V> runPartitions(final Iterable<T> elements, final Function1<List<T>, List<V>> function);  }