I noticed Tom and others said they want Thread abstraction. Here is a simple thread abstraction class that might be a good starting point.
I heard other programmers mention
Boost C++ Libraries has thread abstraction too. I personally never worked with it, but it something to keep in mind, they seem to have quite a few useful libraries.
I've removed the posted code because I don't like how Joomla is displaying the code (there is no syntax highlighting). Instead take a look at the zip file in your favorite editor.