title: Boost Threads and Timers, C++
body: <p>I have this code for a custom class 'sau_timer':</p>
  
  <pre><code>sau_timer::sau_timer(int secs, timerparam f, vector&lt;string&gt; params) : strnd(io), 
      t(io, boost::posix_time::seconds(secs))
  {
      assert(secs &gt; 0);
      this-&gt;f = f;
      this-&gt;params = params;
      t.async_wait(strnd.wrap(boost::bind(&amp;sau_timer::exec, this, _1)));
      boost::thread thrd(boost::bind(&amp;boost::asio::io_service::run, &amp;io));
      io.run();
  }
  
  void sau_timer::exec(const boost::system::error_code&amp;) {
      (f)(params);
  }
  </code></pre>
  
  <p>I want it so that when I make a sau_timer object, the timer will start, but allow program execution to continue. For example, this is main():</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      vector&lt;string&gt; args(1);
      args[0] = "Hello!";
      sau_timer timer_test(3, sau_prompt, args);
      args[0] = "First!";
      sau_prompt(args);
      timer_test.thrd.join();
      return 0;
  }
  </code></pre>
  
  <p>My intention here is that timer_test is made, starting a timer that waits three seconds before calling sau_prompt("Hello!"), but that sau_prompt("First!") will be called first. At the moment, Hello is shown in the prompt before First, indicating that the timer is halting the entire program for three seconds before allowing it to continue. I want the timer to run in the background.</p>
  
  <p>What am I doing wrong? The code compiles...</p>
  
  <p>Thank you.</p>