Boost logo

Boost Users :

Subject: [Boost-users] Thread can not run concurrently with bind parameter
From: coofucoo zhang (coofucoo_at_[hidden])
Date: 2010-06-06 08:06:46


Hi All:
It may be a simple question, but I have no idea now. So I want to post my
question with you. Maybe you can help, thank you.

It is about boost thread.

I want to create a thread and pass a parameter to it. I found there are 2
ways in boost thread, they are:

using bind, like

*boost::thread thrd(boost::bind(&helloworld, "Bob"));*
*thrd.join();*

or construct a structure and do the following:

*boost::thread thrd(helloworld("Bob"));*
*thrd.join();*

It works, really, like the demo code shown. But After I run 2 threads, I
found 2 thread can not run concurrently. The second thread will blocked by
the first thread. If the first thread never exit, the second thread never
run. It is a very funny problem. But I really do not know what happen. Does
anyone know about this topic?

Thank you very much.

-- 
With regards.
Coofucoo Zhang


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net