H
howa
Hello,
I have a method, e.g. foo(int i), which take an integer i and do some
heavy processing
now, i want to find the summation of foo() of i = 1..10000, I want to
take the advantage of speedup by multithreads, then I use executors to
create the threads...,e.g.
public class Foobar implements Runnable {
public Foobar() {}
public void run() {
System.out.println("thread is running...");
}
public int foo(int i) {
//...
}
}
Executor tp = Executors.newFixedThreadPool(10);
for (int i =1; i <=10000; i++) {
tp.execute(new Foobar() );
}
but how can i get back the information return from the execute method,
i.e. from the foo(int i)?
Thanks...
I have a method, e.g. foo(int i), which take an integer i and do some
heavy processing
now, i want to find the summation of foo() of i = 1..10000, I want to
take the advantage of speedup by multithreads, then I use executors to
create the threads...,e.g.
public class Foobar implements Runnable {
public Foobar() {}
public void run() {
System.out.println("thread is running...");
}
public int foo(int i) {
//...
}
}
Executor tp = Executors.newFixedThreadPool(10);
for (int i =1; i <=10000; i++) {
tp.execute(new Foobar() );
}
but how can i get back the information return from the execute method,
i.e. from the foo(int i)?
Thanks...