[thread] is this a bug?

Hello fellow boost fans,
Could anyone explain to me why the destructor (in the program listed
below) seems to be called 10 times but the constructor only one time?
The output of the program is also shown below.
Cheers,
Hector C.
--- BEGIN PROGRAM ---
#include

At 10:59 AM -0700 2/11/08, Hector C wrote:
Hello fellow boost fans,
Could anyone explain to me why the destructor (in the program listed below) seems to be called 10 times but the constructor only one time? The output of the program is also shown below.
I think that adding a copy constructor and/or an assignment operator to your sample will help with your enlightenment. ;-)
--- BEGIN PROGRAM --- #include
#include <iostream> using namespace std;
struct ThreadBug { ThreadBug() { cout << "Begin sending ... " << endl; }
~ThreadBug() { cout << "End sending ... " << endl; }
ThreadBug ( const ThreadBug &rhs ) { cout << "Copy constructing ... " << endl; } ThreadBug & operator = ( const ThreadBug &rhs ) { cout << "Assigning ... " << endl; return *this; }
void operator()() { cout << "Do something ... " << endl; } } w_ThreadBug;
int main() { cout << "New Sequence -----------" << endl; boost::thread thrd(w_ThreadBug); thrd.join(); cout << "End New Sequence -----------" << endl; return 0; } ---END PROGRAM ---
-- -- Marshall Marshall Clow Idio Software mailto:marshall@idio.com It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.
participants (2)
-
Hector C
-
Marshall Clow