您好。我是poco线程类的新用法。 用例: 我正在使用poco tryJoin等待5秒钟..部分代码是
if (Thread.tryJoin( 5000 )){ cout<< 已停止线程成功; } else cout<< 未能停止;问题: 我看到有5秒延迟线程未能停止,如果在上面没有看到延迟,如果情况 并且语句已成功停止线程被打印没有任何延迟 为什么
tryJoin( 5000 )没有延迟? 描述如果tryJoin说它是那个磨坊秒
bool tryJoin( long 毫秒); /// 最多等待线程的给定时间间隔 /// 完成。如果线程已完成,则返回true, /// 否则为false。解决方案
最多等待线程的给定间隔
这意味着它不会等待超过指定的时间。即便如此,它只会在线程仍在运行时等待。 如果您希望在特定时间暂停代码,请使用 睡眠功能 [ ^ ]。
Hi. I am new to the usage of poco thread class. Usecase : I am using poco tryJoin to wait for some 5 sec..part of code is
if(Thread.tryJoin(5000)) { cout<<"stopped thread successfully"; } else cout<<"failed to stop";Problem: I see that there is 5 sec delay if the thread failed to stop, where as the delay is not seen in above if case and the statement "stopped thread successfully" was printed without any delay why no delay when
tryJoin(5000)? Description if tryJoin says that it was for that mill sec
bool tryJoin(long milliseconds); /// Waits for at most the given interval for the thread /// to complete. Returns true if the thread has finished, /// false otherwise. 解决方案 Waits for at most the given interval for the threadThat means that it will not wait longer than the time specified. And even then it will only wait if the thread is still running. If you wish to pause your code for a specific time then use the Sleep function[^].
更多推荐
与poco的tryJoin混淆
发布评论