使用Java进行并行执行
public void doParallel(Runnable... runnables) {
List<Thread> threads = new ArrayList<>();
Arrays.asList(runnables).forEach(runnable -> threads.add(new Thread(runnable)));
threads.forEach(thread -> thread.start());
threads.forEach(thread -> { try { thread.join(); } catch (InterruptedException e) {}});
}
doParallel(
() -> doSomething(),
() -> doSomething(),
() -> doSomething()
);