Suppose we make an api call using multithreading, How would you design to make sure that we have received response for all threads before exiting the main thread ?
More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Q1. Suppose we make an api call using multithreading, How would you design to make sure that we have received response for all threads before exiting the main thread ?
Ans. We can use HashMap for tracking response status for all threads. We can wait every n second by using Thread.sleep and exit the main thread only once we have received response for all threads.
Help us improve. Please let us know the company, where you were asked this question :