[Threads] Problem with starting a sub thread

Hi, im trying to initiate a sub thread for checking some variables during the main program is running: ...do sth... boost::thread checkT(&check); checkT.join(); ...do sth... As I understand boost::threads the second "do sth" should be performed during the thread is running. Well, it doesn't seem so. After experimenting some time it came up that starting two threads like that: boost::thread checkT(&check); boost::thread stopCheckT(&stopCheck); checkT.join(); scheckT.join(); does work, but that: boost::thread checkT(&check); checkT.join(); boost::thread stopCheckT(&stopCheck); scheckT.join(); does not. I really don't understand why. Either .join() stops executing the code (so the scheckT.join() in the first example shouldn't be called) or it doesn't (than the second scheckT should be called too). Where am I wrong? Has anybody an idea? Torsten

Torsten wrote:
Hi,
im trying to initiate a sub thread for checking some variables during the main program is running:
...do sth...
boost::thread checkT(&check); checkT.join();
...do sth...
As I understand boost::threads the second "do sth" should be performed during the thread is running. Well, it doesn't seem so.
checkT.join() blocks and waits for checkT to end.
participants (2)
-
Peter Dimov
-
Torsten