void Detect_4G_model(void *param)
{
while(1) {
/ 检测到插入模块 */
g_4g_status = RUN;
/* 检测到拔出模块 */
g_4g_status = STOP;
}
}
void Send_to_4g_thread(void *param)
{
/ 下面是需要挂起和唤醒的部分*/
while(1) {
/* .... */
}
return NULL;
}
int main(int argc, char * argv[])
{
pthread_create(&tid1, NULL, Detect_4G_model, NULL);
pthread_create(&tid2, NULL, Send_to_4g_thread, NULL);
}
程序有两个线程,线程td1用来检测外部模块的插入和拔出,当检测到拔出时,g_4g_status 设置为 STOP;当检测到插入时,g_4g_status 设置为RUN, 请问,怎么根据g_4g_status 的状态来控制线程Send_to_4g_thread的挂起和唤醒,最好写出点代码,O(∩_∩)O谢谢