【发布时间】:2018-08-06 21:27:21
【问题描述】:
我想检查线程作业是否已完成以再次调用它并向其发送另一个参数。代码是这样的:
void SendMassage(double Speed)
{
Sleep(200);
cout << "Speed:" << Speed << endl;
}
int main() {
int Speed_1 = 0;
thread f(SendMassage, Speed_1);
for (int i = 0; i < 50; i++)
{
Sleep(20);
if (?)
{
another call of thread // If last thread done then call it again, otherwise not.
}
Speed_1++;
}
}
我该怎么做?
【问题讨论】:
-
您可以验证线程尚未完成,但这不会告诉您下一刻(当您实际尝试向其发送某些内容时)它的状态。
标签: c++ multithreading