title: Start multiple threads with Tokio
body: <p>I'm trying to create a basic tcp server:</p>
  
  <ol>
  <li>Server should be able to broadcast a stream of messages to all of the connected clients  </li>
  <li>Server should be able to receive commands from all clients and process them  </li>
  </ol>
  
  <p>This is what I've got in my <code>main</code> function:</p>
  
  <pre><code>let (server_tx, server_rx) = mpsc::unbounded();
  let state = Arc::new(Mutex::new(Shared::new(server_tx)));
  
  let addr = "127.0.0.1:6142".parse().unwrap();
  
  let listener = TcpListener::bind(&amp;addr).unwrap();
  
  let server = listener.incoming().for_each(move |socket| {
      // Spawn a task to process the connection
      process(socket, state.clone());
      Ok(())
  }).map_err(|err| {
      println!("accept error = {:?}", err);
  });
  
  println!("server running on localhost:6142");
  
  let _messages = server_rx.for_each(|_| {
      // process messages here
      Ok(())
  }).map_err(|err| {
      println!("message error = {:?}", err);
  });
  
  tokio::run(server);  
  </code></pre>
  
  <p>(<a href="https://play.rust-lang.org/?gist=35297de9bb6fb6c398d443684bf932c6&amp;version=stable&amp;mode=debug&amp;edition=2015" rel="nofollow noreferrer">playground</a>)</p>
  
  <p>I'm using the <code>chat.rs</code> example from tokio repository as a base.<br>
  I'm sending data to <code>server_tx</code> on incoming tcp messages.<br>
  What I have trouble with is consuming them.<br>
  I'm "consuming" incoming message stream using <code>server_rx.for_each(|_| {</code>, now, how do I tell tokio to run it?  </p>
  
  <p><code>tokio::run</code> accepts a single future, but I have 2 (and possibly more). How do I combine them so they run in parallel?</p>