fork download
  1. import java.text.DateFormat;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5.  
  6. class Main {
  7. public static void main(String[] args) {
  8. Thread th = new Thread(new Runnable() { //cria uma thread
  9. public void run() {
  10. while(true) { //roda indefinidamente
  11. Date date = Calendar.getInstance().getTime(); //pega a hora do sistema
  12. DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
  13. String today = formatter.format(date);
  14. System.out.println(today);
  15. try {
  16. Thread.sleep(1000); //espera 1 segundo para fazer a nova evolução
  17. } catch(InterruptedException ex){
  18. //é algo terrível a se fazer mas pelo jeito a API medonha do Java exige
  19. }
  20. }
  21. }
  22. });
  23. th.start();
  24. }
  25. }
Time limit exceeded #stdin #stdout 15s 37560KB
stdin
Standard input is empty
stdout
11:20:18
11:20:19
11:20:20
11:20:21
11:20:22
11:20:23
11:20:24
11:20:25
11:20:26
11:20:27
11:20:28
11:20:29
11:20:30
11:20:31
11:20:32
11:20:33
11:20:34
11:20:35
11:20:36
11:20:37
11:20:38
11:20:39
11:20:40
11:20:41
11:20:42
11:20:43
11:20:44
11:20:45
11:20:46
11:20:47