title: Is there a way to know if a timerTask has completed?
body: <p>My problem is: I have two blocks of code.. One block I execute only if the Timer reached 10seconds.. so I invoke the TimerTask with the piece of code.. The other block of code I execute only if I don't get into the TimerTask function.. (the run() function).. 
  Is there a way to know if a TimerTask has completed its execution, like returning a Boolean variable, for example? I'm programming in Java.</p>
  
  <p>I tried:</p>
  
  <pre><code>TimerTask emd = new EsperaMensagemDigitada(outgoing, incoming);
  timer.schedule(emd, 10000);
  if(emd.cancel() == true){
     messageOut = userInput.readLine();               
     outgoing.println(messageOut + "            [Sua vez]");
     System.out.println("Aguardando resposta...");
     outgoing.flush();    
  }
  </code></pre>
  
  <p>but it seems that it will ALWAYS execute the code inside the if clausure.. so I dind't resolve my problem yet.. </p>
  
  <p>The other part of this problem is that I have this code: </p>
  
  <pre><code>messageOut = userInput.readLine();
  </code></pre>
  
  <p>I want, if the user doesn't enter any message for 10 seconds I print a default message, if he entered a message until 10 seconds, I print his message. The problem is I get stuck on userInput.readLine(), waiting for an entry.. </p>