use CountDownLatch and ExecutorService to improve Java threading