Delayed start of a thread in C++ 11

前端 未结 6 1956
南方客
南方客 2020-12-01 09:05

I\'m getting into C++11 threads and have run into a problem.

I want to declare a thread variable as global and start it later.

However all the examples I\'ve

6条回答
  •  时光说笑
    2020-12-01 09:28

    You could use singleton pattern. Or I would rather say antipattern.

    Inside a singleton you would have std::thread object encapsulated. Upon first access to singleton your thread will be created and started.

提交回复
热议问题