Hello users.

I observed the boost threads behave strangely, depending on the way I call the function to be executed in parallel.

In the following example (example #1), the threads launched are executed in parallel:
****************************************************************************************
1)
class Test
{

int insert(){};

} object;

boost::thread* threads = new boost::thread[N];
for(unsigned int i = 0; i < N; i++)
 {
     threads[i] = boost::thread(&Test::insert, &object);
 }
****************************************************************************************


However, in the following example (example #2), the threads are executed sequentially. Only the line in the for-loop body differs from example#1.
****************************************************************************************
2)
class Test
{

int insert(){};

} object;

boost::thread* threads = new boost::thread[N];
int ret;
for(unsigned int i = 0; i < N; i++)
 {
     threads[i] = boost::thread(boost::lambda::var(ret) = object.insert());
 }

****************************************************************************************

Can anybody explain why the threads in example#2 are executed sequentially (i.e., one at a time)?

Best Regards,
Panagiotis Foteinos