Suppose I have 2 buffered channels, How can I wait for both of them, and only continue when both of the channel have at least one item in it?
It looks like assemble a machine with two parts, only when both part are at hand can I continue my work.
Both queue are empty, wait.
-------------------
| | | | QUEUE A
-------------------
-------------------
| | | | QUEUE B
-------------------
Queue A has one element but Queue B empty, wait
-------------------
| | | X | QUEUE A
-------------------
-------------------
| | | | QUEUE B
-------------------
Queue A has two elements but Queue B empty, still wait
-------------------
| | Y | X | QUEUE A
-------------------
-------------------
| | | | QUEUE B
-------------------
Both queue has item in it, consume one from each queue.
-------------------
| | Y | X | QUEUE A
-------------------
-------------------
| | | Z | QUEUE B
-------------------
Now, Queue B empty again, wait ...
-------------------
| | | Y | QUEUE A
-------------------
-------------------
| | | | QUEUE B
-------------------