Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. @Configuration
  2. public class YourConfig {
  3.  
  4. @Bean
  5. public TaskScheduler scheduler() {
  6. return new ThreadPoolTaskScheduler();
  7. }
  8. // ...
  9.  
  10. @Service
  11. public class YourTaskRunnable implements Runnable {
  12.  
  13. @Autowired
  14. private TaskScheduler scheduler;
  15.  
  16. @PostConstruct
  17. private void init() {
  18. ScheduledFuture future = this.scheduler.schedule(this, /* to execute immediately, for example */ Calendar.getInstance().getTime());
  19. // ...
  20. }
  21.  
  22.  
  23. @Override
  24. public void run() {
  25. // Your task code ...
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement