Does anybody know where I can get some basic source code on the creation and use of threads (I know about threads, just never coded them, and reading up on them, some of the inputs into CreateThread are confusing)?

Recommended Answers

All 4 Replies

tutorial

If you enter "CreateThread tutorial" in google, you get plenty results.

Before you decide that threads are the magic bullet to fix all your problems, a cautionary tale, and some other approaches (like event based programming) to consider.
http://www.kuro5hin.org/story/2002/11/18/22112/860

If you thought normal debugging was hard, then you've seen nothing which compares to trying to debug race conditions. A more colloquial term would be Heisenbug.

class myClass
{
public:
void init();

private:
void WINAPI Thread();
};

void WINAPI myClass::Thread()
{
    //do whatever
}

void init()
{
   CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Thread, 0, 0, 0);
}

This is just a quick psuedo for a much larger program. The error I get is ...

error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'LPTHREAD_START_ROUTINE'

This is how i read to start a simple thread, did I do something wrong?

Thanks.

I needed to declare the function, whose address was being passed to the thread, as static, in case anyone has this problem in the future.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.