gpt4 book ai didi

c - 如何判断哪个pthread唤醒了pthread? C

转载 作者:太空宇宙 更新时间:2023-11-04 00:00:23 25 4
gpt4 key购买 nike

我目前正在研究多线程编程。我有几个客户 pthread 和两个职员 pthread(A 和 B)。每个客户 pthread 都有一个唯一的 id、arrival_time 和 service_time。客户线程最初处于休眠状态,等待职员线程唤醒。我的问题是如何找到每个客户线程都被职员 pthread A 或职员 pthread B 唤醒?

谢谢

最佳答案

可以使用pthread条件变量机制。不要对客户线程使用 sleep ,而只需使用 pthread_cond_wait() 并由您的职员线程唤醒。

关于c - 如何判断哪个pthread唤醒了pthread? C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47150037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com