Beginner needs help with Boost thread class

Hello, I am completely new to Boost and I would like to know in which method to put the business logic (work) of my thread class (which inherits from boost::thread). When you do that in Java you implement Runnable and put the business logic in the run() method. How do I do that with boost? Thanks in advance, Julien.

I am completely new to Boost and I would like to know in which method to put the business logic (work) of my thread class (which inherits from boost::thread). When you do that in Java you implement Runnable and put the business logic in the run() method. How do I do that with boost?
Look into the documentaiton: http://www.boost.org/doc/libs/1_44_0/doc/html/thread/thread_management.html You do not inhertit from boost::thread, you pass your thread function to thread's constructor.

On 10/19/2010 04:04 AM, Julien Martin wrote:
Hello, I am completely new to Boost and I would like to know in which method to put the business logic (work) of my thread class (which inherits from boost::thread). When you do that in Java you implement Runnable and put the business logic in the run() method. How do I do that with boost? Thanks in advance, Julien.
Hello Julien - Boost threads are nothing like Java thread classes or the Runnable interface. The boost thread interface takes a function or function object that it then begins running right away. If you are approaching this from a Java background I suggest you start by forgetting all about Java thread objects and start as if you know nothing about threads as objects. This page http://www.boost.org/doc/libs/1_44_0/doc/html/thread/thread_management.html will hopefully get you started. The boost::thread documentation is well written and you will want to take some time familiarizing yourself with what boost (and the c++ standards committee) think a thread is. Feel free to ask questions as they arise. Welcome to Boost and good luck! michael -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

Thanks to both of you.
2010/10/19 Michael Caisse
On 10/19/2010 04:04 AM, Julien Martin wrote:
Hello, I am completely new to Boost and I would like to know in which method to put the business logic (work) of my thread class (which inherits from boost::thread). When you do that in Java you implement Runnable and put the business logic in the run() method. How do I do that with boost? Thanks in advance, Julien.
Hello Julien -
Boost threads are nothing like Java thread classes or the Runnable interface.
The boost thread interface takes a function or function object that it then begins running right away. If you are approaching this from a Java background I suggest you start by forgetting all about Java thread objects and start as if you know nothing about threads as objects.
This page < http://www.boost.org/doc/libs/1_44_0/doc/html/thread/thread_management.html>http://www.boost.org/doc/libs/1_44_0/doc/html/thread/thread_management.htmlwill hopefully get you started. The boost::thread documentation is well written and you will want to take some time familiarizing yourself with what boost (and the c++ standards committee) think a thread is.
Feel free to ask questions as they arise. Welcome to Boost and good luck!
michael
--
Michael Caisse Object Modeling Designswww.objectmodelingdesigns.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Igor R
-
Julien Martin
-
Michael Caisse