I have the following Foo
class that uses FooProcessor
class. So what i want to do is, while running cp1 instance process method, in parallel I want to run cp2.process()
.
public class Foo {
public static void main(String [] args){
FooProcessor cp1 = new FooProcessor();
FooProcessor cp2 = new FooProcessor();
cp1.process();
// in parallel process cp2.process();
}
}
public class FooProcessor {
public void process(){
System.out.println("Processing..");
}
}
However, i want cp1 sequentially, so i want it to run and complete, if cp2 doesnt complete or fails it is fine. If it doenst fail i want to join the results. It is not returning anything in this sample but I want to return result.
For this purpose, should is use TaskExecutor? or Thread?
I want only cp2 to run in parallel to cp1. or if i add more lets say cp3, i want that to run in parallel as well to cp1.