c - 如何终止无限循环(线程)

c - 如何终止无限循环(线程)

我对退出 while 循环有疑问。我正在编写代码,其中创建了两个线程,它们打印字符串,而 main() 部分必须每 500 毫秒打印一次点 (".")。你能帮我在第二个线程终止后如何退出while循环,以便在输出中得到类似的东西:...Hello...World....THE END

感谢您的帮助。

int main()

{

int mls = 0.5 ;

pthread_t thread1;

pthread_t thread2;

struktura param1 = { "Hello", 2};

struktura param2 = { "World", 4};

pthread_create( &thread1, NULL, thread, ¶m1);

pthread_create( &thread2, NULL, thread, ¶m2);

while(1)

{

printf(".");

fflush(stdout);

sleep(mls);

}

pthread_join(thread1, NULL);

pthread_join(thread2, NULL);

printf("THE END\n");

return 0;

}

相关推荐

8、王者铭文碎片怎么买
求正规英国365网址

8、王者铭文碎片怎么买

📅 07-22 👁️ 1110
小学生如何练字?小学生练字全攻略(附2年级字帖)
365彩票软件app下载

小学生如何练字?小学生练字全攻略(附2年级字帖)

📅 08-11 👁️ 9893
中国所有歌手名单,中国歌手名单大全
求正规英国365网址

中国所有歌手名单,中国歌手名单大全

📅 07-11 👁️ 5098
爱聊免费网络电话是不是真的
365彩票软件app下载

爱聊免费网络电话是不是真的

📅 08-12 👁️ 2195
《约束之地》详细流程攻略
365彩票软件app下载

《约束之地》详细流程攻略

📅 07-15 👁️ 3979
10个好用的百度网盘、阿里云盘、夸克网盘资源搜索网站分享推荐