I have 2 independent tasks to execute. I need the result of Task1 first followed by task2.
Which of the below 2 ways is better in terms of number of threads and performance(if at all) and why ? Will there be any performance difference between the 2 methods ?
Method1:
1. Execute Task1 & Task2 asynchronously by submitting them to ExecutorService
2. Get the results by calling future1.get() followed future2.get()
Method2:
1. Execute task2 asynchronously by submitting it to ExecutorService.
2. Execute Task1 on main thread
3. Get the result of task2 by calling future2.get()