A common problem in concurrent programming is when you have various concurrent tasks that solve a problem, and you are only interested in the first result of those tasks. For example, you want to sort an array. You have various sort algorithms. You can launch all of them and get the result of the first one that sorts these, that is, the fastest sorting algorithm for a given array.
In this recipe, you will learn how to implement this scenario using the
ThreadPoolExecutor class. You are going to implement an example where a user can be validated by two mechanisms. The user will be validated if one of those mechanisms validates it.
The example of this recipe has been implemented using ...