The answers to your questions for me:
How many times do you call 'c1.await()'
4 times because I call the method performTask 4 times
what count are your CyclicBarriers constructed
count is equal to 3 for both c1 and c2
what about the size of your ThreadPool
the pool contains 4 available threads
According to the definition : The CyclicBarrier takes in its constructors a limit value, indicating the number of threads to wait for. As each thread finishes, it calls the await() method on the cyclic barrier. Once the specified number of threads have each called await(), the barrier is released and all threads can continue.
I think I got it, the answer to my question is here "Once the specified number of threads have each called await(), the barrier is released". Since the await() is called by 4 threads, the first three threads allow to release the barrier but the last (the 4th) thread calls await and waits for 2 other threads to call await() in order to be released, since these 2 other threads never come, the program hangs in await() method called by the 4th thread. If my understanding is true, if I call performTask 6 times (or any multiple of 3), it will not hang anymore => I have tested and that's indeed the case.
Do you confirm my understanding sir Piet?