Multithreading beginner problem

Discussion in 'C++' started by Lee Garrington, Dec 22, 2003.

  1. 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
     
    Lee Garrington, Dec 22, 2003
    #1
    1. Advertising

  2. Lee Garrington wrote:
    > 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 news:comp.lang.c++ 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
     
    Thomas Matthews, Dec 22, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    No Class at ALL!!! beginner/beginner question

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    653
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Feb 3, 2005
  2. insomniac

    ASP.Net 2.0 Multithreading Problem

    insomniac, Apr 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,767
    insomniac
    Apr 27, 2006
  3. Rensjuh
    Replies:
    7
    Views:
    1,041
    Mabden
    Sep 2, 2004
  4. Replies:
    1
    Views:
    3,183
    bruce barker \(sqlwork.com\)
    May 11, 2006
  5. william nelson

    Beginner's Beginner

    william nelson, Apr 11, 2011, in forum: Ruby
    Replies:
    7
    Views:
    261
    7stud --
    Apr 12, 2011
Loading...

Share This Page