Answers for "java run code at interval"

0

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);
Posted by: Guest on February-15-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language