Why threads order yields different results for fork...join_none?

In reply to dave_59:

Thanks for your reply, dave.
Actually one thing I want to understand is that


fork
consumer();
producer(0);
producer(1);
producer(2);
join_none

at #0, why checker_data.num() == 0?

fork
producer(0);
producer(1);
producer(2);
consumer();
join_none
at #0, why checker_data.num() == 3?

First, for the case that multiple threads share one mailbox, how to make sure that user can predict the result?
Second, based on your suggestion to avoid add #1, one problem is that the while-loop will never advance without delay. Can you give some more details on how to improve this consumer task?

Thanks.