'How to stop thread from execution if certain condition is met
Say I have a service that tries to load the data from DB, if data does not exist in DB, It tries to load from master DB and if it is not found there as well it will try to fetch from another API.
This is a business requirement given by the client for loading the data.
How we can reduce the response time of my rest endpoint in a worst-case scenario?
I am trying to use an executor service framework to spawn multiple threads to run asynchronoulsy, but I don't know how to stop the execution of the remaining threads if one of the threads returns the successful response(loads data). Any help on this is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
