
While trying to understand the difference between wait() and async_wait, I modified the tutorial example a little to test 2 timers at the same time like this: int test_timer() { boost::asio::io_service io; size_t delay1 = 5; size_t delay2 = 3; boost::asio::deadline_timer t1(io, boost::posix_time::seconds(delay1)); boost::asio::deadline_timer t2(io, boost::posix_time::seconds(delay2)); boost::timer t; t2.wait(); std::cout << t.elapsed() << " sec elapsed!\n"; t1.wait(); std::cout << t.elapsed() << " sec elapsed!\n"; return 0; } I got this output: 3.004 sec elapsed! 5.007 sec elapsed! However, I was expecting t2 and t1 to execute sequentially and thus getting: 3.004 sec elapsed! 8 sec elapsed! What was wrong with my understanding about synchronous waiting here? Thanks.