title: Boost Asio, Multiple threads and multiple io_service
body: <p>I want to develop a server use multiple threads and multiple io_service instance(each thread use an io_service instance) to listen at a port. For each io_service instance I create a corresponding boost::asio::ip::tcp::acceptor object. I try this code:</p>
  
  <pre><code> using namespace boost::asio;
      ...
      io_service io_service_;
      io_service io_service_1;
  
      ip::tcp::acceptor* acceptor_;
      acceptor_ = new ip::tcp::acceptor(io_service_);
      ip::tcp::endpoint ep( ip::tcp::v4(), LISTEN_PORT);
      acceptor_-&gt;open(ep.protocol());
      acceptor_-&gt;bind(ep);
      acceptor_-&gt;listen();
  
      ip::tcp::acceptor* acceptor_1;
      acceptor_1 = new ip::tcp::acceptor(io_service_1);
      acceptor_1-&gt;open(ep.protocol());
      acceptor_1-&gt;bind(ep);
      acceptor_1-&gt;listen();
      ...
  
      boost::thread th( boost::bind(&amp;io_service::run, &amp;io_service_));
      boost::thread th( boost::bind(&amp;io_service::run, &amp;io_service_1));
      ...
  </code></pre>
  
  <p>when running will display error dialog: </p>
  
  <blockquote>
    <p>boost::exception_detail::clone_impl&lt; boost::exception_detail::error_info_injector > at memory location 0x001FF704.</p>
  </blockquote>
  
  <p>can you help me how to make a server with Multiple threads, each thread use an io_service instance?</p>
  
  <p><strong>Update:</strong> as I read in Boost.Asio C++ Network Programming, have 3 way to use io_service with thread:</p>
  
  <ol>
  <li>Single-thread with one io_service and one handler thread(thread running io_service::run())</li>
  <li>Multi-threaded with a single io_service instance and several
  handler threads</li>
  <li>Multi-threaded with several io_service instances and several threads</li>
  </ol>
  
  <p>I can implement case 1 and 2. But with case 3, I don't know how to implement it to handle many concurrent connections, should I use 1 thread to handle 1 io_service(as above)? Is case 3 has better performance(can handle more concurrent connections) than case 2? </p>