I am working on a project in which I have multiple interface and two Implementations classes which needs to implement these two interfaces.
Suppose my first Interface is
You can use java.lang.Thread for parallel execution. However, in most cases it's easier to use an java.util.concurrent.ExecutorService. The latter provides a method to submit a Callable and returns a Future to get the result later (or wait for completion).
If testA.abc() and testB.xyz() should be executed in parallel, you use the ExecutorService to execute the former in a separate thread whereas the latter is executed in the original thread. Then you wait for the completion of the former for synchronization.
ExecutorService executor = ... // e.g. Executors.newFixedThreadPool(4);
Future future = executor.submit(new Callable() {
public Void call() throws Exception {
testA.abc();
return null;
}
});
testB.xyz();
future.get(); // wait for completion of testA.abc()