a question about boost thread

hi everyone
i want to write a multithread program with libboost_thread but the problem is that it only supports functions with no arguments what should i do if iwnat to use it with arguments ?
i believe you can use the bind() function provided by the boost::bind library


boost::thread your_thread( boost::bind(&your_function, param1, param2, .....) );


In this way, you can bind parameters to the function and they will be passed in as normal.
Last edited on
Newer versions of the Boost Thread Library permit this without using bind().

Search for "Thread Constructor with arguments" at http://www.boost.org/doc/libs/1_40_0/doc/html/thread.html

But a solution for older versions of Boost is to use a functor and pass the arguments to its constructor. Example here: http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html
Topic archived. No new replies allowed.