According to cppreference.com, std::thread constructor with no parameter means:
Creates new thread object which does not represent a thread.
my questions are:
- why do we need this constructor? And if we create a thread using this constructor, how can we "assign" a thread function later?
- Why don't we have a "run(function_address)" method so that when constructed with no parameter, we can specify a function to "run" for that thread.
- Or, we can construct a thread with a callable parameter(function, functors, etc.) but call a "run()" method to actually execute the thread later. Why std::thread is not designed in this way?
Aucun commentaire:
Enregistrer un commentaire