Suppose I have a blocking method called check as follows:
boolean check(String input) {}
which will do some check against the input and return the decision.
Now I want to run this check against a list of inputs asynchronously, and I want to return to the main thread right after one of the inputs passing the check, so I don't have to wait for all asynchronous call to be completed. The only one scenario for waiting all threads to complete is that there are no inputs passing the check. Running the method asynchronously with list of inputs is straightforward but I'm not sure how to return to the main thread after getting the target output for the input passing the check.