/* 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>

#include <windows.h>

using namespace std;

CRITICAL_SECTION cs;

DWORD __stdcall thread(void *p)
{
    string *link = (string *)p;
    EnterCriticalSection(&cs); 
    cout << "Du åbnede tråden med sætningen: " << *link << endl;
    LeaveCriticalSection(&cs);
}

int main()
{
    InitializeCriticalSection(&cs);
    string input[2] = { "dette er en streng!", "dette er en anden streng!" };
    DWORD id[2];
    CreateThread(0, 0, thread, &input[0], 0, &id[0]);
    CreateThread(0, 0, thread, &input[1], 0, &id[1]);
    cin.get();
    return 0;
}
