I have the following scenario:
Thread A will send a number of tasks to both Thread B and C. (the exact number of tasks is unknown)
For each of the tasks, thread A will send it to B and C at the same time (asynchronously), and then if either of the B or C finished the task successfully or both failed, A would continue to send the next task. The idea here is to avoid blocking as much as possible. i.e., for the same task, when B finished it while C is still processing, A can send next task immediately and don't need wait for C to get the result.
it's expected that the slower one in B and C can skip some tasks as long as the task is done by the other. For example, B may finish task t1 t2 t3 t4, and C only finish t1 t4 due to that when C received t2 and t3, it's still processing t1 for some reason.
is there any thread synchronization construct suitable for this? I am checking java.util.concurrent.Phaser, but seems it doesn't fit my need. Any comments are welcome, thanks in advance.