title: Handle multiple user at the same time with TelegramLongPollingBot and thread
body: <p>I'm building my first telegram bot. It send one message every 5 seconds to the user.</p>
  
  <p>While it sends it to one user it cannot receive update from other chat.</p>
  
  <pre><code>public void foo(msg, Update update){
      msg.setChatId(update.getMessage().getChatId());
      for (int i = 1; i &lt; links.size(); i++){
          msg.setText(links.get(i));
          execute(msg);
      }
      Thread.sleep(wait * 1000);
  }
  </code></pre>
  
  <p>How can I use Thread? I've tried creating multiple thread here</p>
  
  <pre><code>public static void bot(){
  
      ApiContextInitializer.init();
      TelegramBotsApi  telegramBotsApi = new TelegramBotsApi();
      try {
          telegramBotsApi.registerBot(new myBot());
      } catch (TelegramApiException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>But he tries to create multiple bots and fails. Same if this is the runnable function:</p>
  
  <p>How can I do it? I'm Stuck. I cannot create this function in different thread</p>
  
  <pre><code>public void onUpdateReceived(Update update) {
  
      leggi(new SendMessage(), update.getMessage().getText(),  update);
  
      //.setChatId(update.getMessage().getChatId())
  
  
  public void  leggi(SendMessage msg, String command, Update update){ 
      if(command.equals("test") {
          foo( msg, update);
      }
  </code></pre>
  
  <p>Here the full code...  <a href="https://github.com/siamoInPochi/Ilsottomarinobot/tree/prova/src/main/java/Ilsottomarinobot" rel="nofollow noreferrer">https://github.com/siamoInPochi/Ilsottomarinobot/tree/prova/src/main/java/Ilsottomarinobot</a></p>