Monica. Shiralkar wrote:
In that case how to measure the total time taken for the application?
You need a way to determine that all the tasks in the thread pool has been completed. For example, the executor service class provided by
Java provides a way to determine the completion of an orderly shutdown -- so a quick and dirty option, after adding all the tasks to the executor would be to (orderly) shutdown the executor and await its termination. When all the tasks completes, the thread pool will shutdown and the main thread will wake up.
Now, if you are thinking that shutting down executor is extreme, I kinda agree... so, alternatively, you can track the amount of files processed. For example, at the end of the task, you simply increment a thread safe variable. And when the count reaches the expected value, the main thread can determine the stop time.
Henry