Thanks for your reply!
It seems to me that after thread B awakens by signal1 of thread A, since thread A holds myMutex, thread B must immediately block on the myMutex. Thread A continues until it waits for signal2 and release myMutex. THen thread B gets the chance to run. I think by the time thread B broadcasts, thead A should have already been waiting.
Also if it is the scenario as you said, the problem should not be solved by letting thread B sleep(1) before broadcast.
(Please note that I only have this problem when I run it on a single processor machine. No problem if run on 2-CPU machine.)