Use a ScheduledExecutorService:
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(yourRunnable, 8, 8, TimeUnit.HOURS);
More Related Contents:
- Java Timer vs ExecutorService?
- Scheduling a job with Spring programmatically (with fixedRate set dynamically)
- Background timer task in JSP/Servlet web application [duplicate]
- How to stop a scheduled task that was started using @Scheduled annotation?
- Spring scheduling task – run only once
- How to conditionally enable or disable scheduled jobs in Spring?
- How to change Spring’s @Scheduled fixedDelay at runtime?
- How to use Timer class to call a method, do something, reset timer, repeat?
- Does spring @Scheduled annotated methods runs on different threads?
- Android Timer schedule vs scheduleAtFixedRate
- How I can run my TimerTask everyday 2 PM?
- Is having a single threadpool better design than multiple threadpools
- java timer task schedule
- scheduleAtFixedRate vs scheduleWithFixedDelay
- How to stop a Runnable scheduled for repeated execution after a certain number of executions
- How to generate exceptions from RepaintManager
- How to access the Java method in a C++ application
- Using == operator in Java to compare wrapper objects
- Bubble sort animation
- Hiding certain methods from other packages
- How can I add rows and columns to a JavaFX 8 TableView
- What does void do in java?
- How to run bootRun with spring profile via gradle task
- Java GSON: Getting the list of all keys under a JSONObject
- Android session management
- HyperlinkListener in JavaFX WebEngine
- Convert a map of lists into a list of maps
- How do I disable resolving login parameters passed as url parameters / from the url
- How to remove element from an array
- How to transmit live video from within a Java application?