There is no better way, in general, than having a separate Start
function.
Suppose MyClass
is a base class for some future (unknown) class Derived
. If the thread is started while (or before) the MyClass
constructor runs, it always risks calling the "wrong" implementation of some virtual function overridden by Derived
.
The only way to avoid this is to have the thread wait until after Derived
is fully constructed, and the only way to do that is to call some other function after the Derived
constructor completes to tell the thread to "go"... Which means you must have some kind of separately-invoked Go
function.
You might as well just have a separately-invoked Start
function instead and forego the complexity of waiting.
[Update]
Note that, for complex classes, "Two-Phase Construction" is an idiom recommended by some. Starting the thread would fit seamlessly into the "initialization" phase.