fork download
  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;
  3. import java.util.Timer;
  4. import java.util.TimerTask;
  5.  
  6. class Captura {
  7. Timer timer;
  8.  
  9. public void criarTimer(int segundos) {
  10. TimerTask timerTask = new TimerTask() {
  11. public void run() {
  12. System.out.print(new SimpleDateFormat("HH:mm:ss").format(new Date()));
  13. System.out.println(" Captura de webcan!");
  14. }
  15. };
  16. int segundosParaComecar = 0;
  17. int segundosParaCapturar = segundos*1000;
  18. timer = new Timer();
  19. timer.schedule(timerTask, segundosParaComecar, segundosParaCapturar);
  20. }
  21.  
  22. public static void main(String args[]) {
  23. Captura reminder = new Captura();
  24. reminder.criarTimer(1);
  25. System.out.println("Começo do timer");
  26. }
  27. }
Time limit exceeded #stdin #stdout 5s 1105920KB
stdin
Standard input is empty
stdout
Começo do timer
13:27:42 Captura de webcan!
13:27:43 Captura de webcan!
13:27:44 Captura de webcan!
13:27:45 Captura de webcan!
13:27:46 Captura de webcan!
13:27:47 Captura de webcan!
13:27:48 Captura de webcan!
13:27:49 Captura de webcan!
13:27:50 Captura de webcan!
13:27:51 Captura de webcan!
13:27:52 Captura de webcan!