小编xDi*_*dex的帖子

如何停止正在运行的pthread线程?

如何立即退出或停止线程?

当用户输入答案时,如何立即停止?我想让它重置每一个问题.

这是涉及线程的代码

int q1() {
    int timer_start;
    char ans[] = "lol";
    char user_ans[50];
    timer_start = pthread_create( &xtimer,NULL,(void*)timer_func,(void*)NULL);
    printf("What is the capital city of Peru?\n");

    while(limit){
        scanf("%s",user_ans);
        if(limit)
        {
             if(!strcmp(user_ans, ans))
              {

               // printf("YAY!\n");
                score++;
               // q2();

            }
            else
            {
                game_over();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c multithreading pthreads

5
推荐指数
3
解决办法
4万
查看次数

标签 统计

c ×1

multithreading ×1

pthreads ×1