Java Timertask is a performatic solution to schedule multiple and concurrent processes to your application. The schecludedAt of a TimerTask haves a fast perform better than Thread sleep. Your process is hidden to JVN, and run only at scheduled configured time.
See a simple standalone class example:
public class TaskTestMainClass {
// static instance to use only one instance of Timer object
private static Timer t = new Timer();
public static void main(String[] args) {
t.schedule(new TimerTask() {
public void run() {
System.out.println("My specific command.");
// System.exit(0); // to finish the execution on a standalone batch mode
}
}, 1000);
}
}
Nenhum comentário:
Postar um comentário