how to run interval in java code example
Example: java run code at interval
/* Perform this runnable code every 5 seconds in this example*/
Runnable runnable = new Runnable() {
public void run() {
// task to run goes here
System.out.println("Hello !!");
}
};
ScheduledExecutorService service = Executors
.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(runnable, 0, 5, TimeUnit.SECONDS);