Reusing thread in loop c++

前端 未结 6 1044
余生分开走
余生分开走 2020-11-29 02:45

I need to parallelize some tasks in a C++ program and am completely new to parallel programming. I\'ve made some progress through internet searches so far, but am a bit stu

6条回答
  •  既然无缘
    2020-11-29 03:22

    This

     std::thread acq1(...)
    

    is the call of an constructor. constructing a new object called acq1

    This

      acq1(...)
    

    is the application of the () operator on the existing object aqc1. If there isn't such a operator defined for std::thread the compiler complains.

    As far as I know you may not reused std::threads. You construct and start them. Join with them and throw them away,

提交回复
热议问题