Boost logo

Boost Users :

Subject: [Boost-users] ASIO Tutorial 5 - Synchronising handlers in a multithreaded programs - Doesn't use both threads for processing
From: mark (markcsu_at_[hidden])
Date: 2009-05-16 03:54:39

Using the code from
with a few extra cout's for extra info.

If you print out the thread IDs of at the start of print1 and print2 you'll
see that both methods are actually using the same thread. ie two threads
gets created but only one does any work.

I'm printing the thread ID's via
std::cout << "print1 " << boost::this_thread::get_id() << std::endl;
std::cout << "print2 " << boost::this_thread::get_id() << std::endl;

at the top of print 1 and print 2.

I first noticed this when I was single line stepping through the code trying
to work out how the second thread could possibly be doing anywork since
t.join() is called after Also if I comment out the
program still works the same as before, except its the second thread doing
all the processing.

Compiler MSVC 9.0, happens on both debug and release.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at