Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-22 17:56:37


Tim Laplaca wrote:
> boost::thread_group thrds;
>
> objclass * objthread;
>
>
>
> objthread = new objclass;
>
> thrds.create_thread( (objthread->p) );

Do this instead:

    boost::shared_ptr<objclass> objthread( new objclass );
    thrds.create_thread( boost::bind( &objclass::dowork, objthread ) );

Even better, drop the objclass entirely and do this:

    void dowork( int tid, string valtwo )
    {
        // do work
    }

    thrds.create_thread( boost::bind( dowork, my_thread_id, my_valtwo ) );


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk