I'm learning executor service in java. Requirement is using executor service create 4 threads -
Thread 1 - get two numbers as input.
Thread 2 - addition of two numbers
Thread 3 - multiplication of two numbers
Thread 4 - print the results.
Thread 1 should be executed first, after thread 1 is complete thread 2, 3 can start processing simultaneously and finally once thread 2, 3 is completed. Thread 4 should run finally.
How can we make sure which thread starts first and which threads to start simultaneously next. Finally which thread to execute at last.
Note: How can we achieve this without using thread sleep. Dynamically as soon as thread 1 finishes other two threads should start automatically.