My problem is, I have two threads t1 and t2. Both of them make some calculations, and according to my program, I want to use a concurrency technique that blocks till t1 and t2 both finish their tasks and then continue.
I tried countdownLatch
, and I read about ExecutorService
and made a small example. Concerning the ExecutorService
I did something like the following:
executor.execute(new RunnableClass(bgr,3))
executor.execute(new RunnableClass(bgr,7))
executor.shutdown();
if (executor.isTerminated()) {
print("terminated")
}
and the word "terminated" was never printed, which means executorService
object does not block.
please let meknow whih concurrency technique i should use to suit my situation