[quote user="newfweiler"]
[quote user="UnFleshed One"]Now just make you code to do something usefull :)
"delete new what" actually have a load, it calls constructor (and then destructor) and fires off the whole engine :)[/quote]
Oh, well, I can improve on this then.
Add to "what" a constructor that takes an int:
what::what(int a) {
// Copy of text of default constructor goes here
}
Then, in a different file, define a misleading function that takes a what:
void sleepForNMilliseconds(what w) {
// Sleep for the number of milliseconds given in the parameter
// so that the other thread has a chance to catch up and we can
// use its data without having to lock it.
// TODO: Implement this only if it turns out I need it.
}
Then you just have to put this somewhere where it gets executed:
// Start up the other thread ...
...
// Give the other thread some time to work
sleepForNMilliseconds(500);
// Forcibly shut down the other thread
...
A"what" will be constructed from the int to pass to sleepForNMilliseconds (and destroyed soon after). (This is why most constructors that take only one parameter should be marked "explicit".) So the code that does all the work runs even though it never appears to be called at all!
[/quote]
Now you just need to rename what as something like Int or integer and no one will even suspect anything when they see the sleepForNMilliseconds() function.