4. public class ProcesoRepetible implements Runnable { public void run() { //De momento no hace nada } public void execute() { //Aquí dentro definiriamos nuestra operación System.out.println(“Mensaje a consola”); } }
5.
6. private int minutos; //Ultimo momento de ejecución Date ultima = new Date(); public ProcesoRepetible(int minutos) { this.minutos = minutos; } public void run() { while(true) { try { Date ahora = new Date(); long dif = ahora.getTime() – ultima.getTime(); if(dif >= (minutos * 60000)) { execute(); ultima = ahora; } Thread.sleep(minutos * 60000); } catch(Exception e) { ; } } }