// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

using namespace std;

#include <windows.h>

DWORD __stdcall dispatcher(void *p);

class X
{
    private:
        int v;
    public:
    X(int v) { this->v = v; };
    void Doit() { cout << v << endl; };
    void Start() { HANDLE h = CreateThread(NULL,0,dispatcher,this,0,NULL);
                   WaitForSingleObject(h,INFINITE); }
};

DWORD __stdcall dispatcher(void *p)
{
    X *x = (X *)p;
    x->Doit();
    return 0;
}

int main()
{
    X *x = new X(123);
    x->Start();
    return 0;
}
