1) Allocate a string (object of CString class) - but not on stack. You can make it a global or a member of the application class, or even create it dynamically.
2) Create a new thread using AfxBeginThread and pass it the address of your string object, e.g.
AfxBeginThread(YourThreadFunction, &g_MyString, THREAD_PRIORITY_NORMAL);
3) inside your thread function (e.g. YourThreadFunction), cast LPVOID p to CString * in the beginning and then you can use it as a pointer to string in your thread's loop:
INT YourThreadFunction(LPVOID p)
{
CString *pStr = (CString *)p;
while (!gCancel)
{
}
return 0;
}
It is of course crude as, but you get the idea. All the usual pre-cautions about simultaneous access, reallocation and so on will still apply.
I normally create a thread interface class that contains everything that is needed to pass data between 2 threads - which could contain strings amongst other things.