I have a scenario where I need to ensure the following :
- UI, on button click makes a GET call to an API and waits for a response.
- API method has to perform two tasks X and Y on the GET request, but it should return X's response as soon as it gets it and performs Y in the background.
- UI is not aware if Y succeeds or not.
The challenge I am facing is returning a response back for X and at the same time triggering Y in parallel. Any safe thread pattern that can be followed here?