Multithreading beginner problem

L

Lee Garrington

Hello,

I am having a bit of a problem with multithreading in C++. After reading
through 2 tutorials and implementing it in what looks the same way, it still
does not compile. Basically, how do I start a function as a separate thread
in a class?

I have the following functions defined...

void Solver::Start()
{
hThreadHandle = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &iThreadId);
}

static DWORD WINAPI ThreadProc(Solver *s)
{
return s->Solve();
}

DWORD Solver::Solve()
{
//do some stuff
return 0;
}

I just keep getting a typecast error. Can someone either tell me where I
went wrong or provide me with an explanation of how to do it properly?

Thx in advance

Lee
 
T

Thomas Matthews

Lee said:
Hello,

I am having a bit of a problem with multithreading in C++. After reading
through 2 tutorials and implementing it in what looks the same way, it still
does not compile. Basically, how do I start a function as a separate thread
in a class?
[snip]
Sorry, but threading is not discussed in since
there are no facilities for threading in _standard_ C++. Please
consult a newsgroup about your platform or compiler.

Read the FAQ and Welcome.txt which can be found at the links
below.
Thx in advance

Lee


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top