Hi,
I have 6 Java threads to perform specific tasks in 2 steps.
step1: First 3 should only execute, other 3 should wait.
step2: After step1 completes, other 3 threads should start execution.
Can anyone pls tell how can I achieve this in Java....?
Printable View
Hi,
I have 6 Java threads to perform specific tasks in 2 steps.
step1: First 3 should only execute, other 3 should wait.
step2: After step1 completes, other 3 threads should start execution.
Can anyone pls tell how can I achieve this in Java....?
make last 3 threads wait with, well, wait() method, when first three threads complete, invoke notifyAll(), which allows waiting threads to complete.
why do you need thread to do this job? why cant first three threads handle the next three tasks too? I am just trying to understand the use case that may make your code complicated.