Here's an example of the kind of threading I've done:
Code:
#include <iostream>
#include <string>
#include <windows.h>
bool printing = false;
void PrintingFunction(std::string s)
{
int i;
for (i = 0; i < 100; i++)
{
while (printing);
printing = true;
std::cout << s << '\n';
printing = false;
Sleep(100);
}
}
unsigned long __stdcall ThreadFunction(void* data)
{
PrintingFunction("Secondary Thread");
return (unsigned long)data;
}
int main()
{
void* threadHandle;
unsigned long threadID;
threadHandle = CreateThread(NULL, 0, ThreadFunction, NULL, 0, &threadID);
PrintingFunction("Main Thread");
WaitForSingleObject(threadHandle, INFINITE);
CloseHandle(threadHandle);
return 0;
}
Is that acceptable, outdated, obsolete...?