Lock l;//任何一种同步机制,锁,信号量,临界区等,你懂的void threadBfun{ //该干嘛干嘛 lock(l); //由A控制是否跳转的代码}void threadAfun{ unlock(l);}