If I understood you well, you want to create parallelism on different task execution and then wait for the completion of all of them to continue. Is this what you want? If your answer is "yes", then maybe you could use the "fork/join" framework (Java 7)
Here is a code snippet, taken from this Brian Goetz (IBM Java guru) article:
public class MaxWithFJ extends RecursiveAction {
private final int threshold;
private final SelectMaxProblem problem;
public int result;
public MaxWithFJ(SelectMaxProblem problem, int threshold) {
this.problem = problem;
this.threshold = threshold;
}
protected void compute() {
if (problem.size < threshold)
result = problem.solveSequentially();
else {
int midpoint = problem.size / 2;
MaxWithFJ left = new MaxWithFJ(problem.subproblem(0, midpoint), threshold);
MaxWithFJ right = new MaxWithFJ(problem.subproblem(midpoint +
1, problem.size), threshold);
coInvoke(left, right);
result = Math.max(left.result, right.result);
}
}
public static void main(String[] args) {
SelectMaxProblem problem = ...
int threshold = ...
int nThreads = ...
MaxWithFJ mfj = new MaxWithFJ(problem, threshold);
ForkJoinExecutor fjPool = new ForkJoinPool(nThreads);
fjPool.invoke(mfj);
int result = mfj.result;
}
}
Otherwise, if don't want any parallelism and just want to wait some time, use Thread.Sleep(int miliseconds)
function.