This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to substitute a Timer for ScheduledThreadExecutor  RSS feed

 
Jake Kowalski
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


How to replace this code:



With a ScheduledThreadExecutor

EDIT: Here is what happens in startSync();


 
Stephan van Hulst
Saloon Keeper
Posts: 7806
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Executors has methods that return a ScheduledExecutorService, which in turn has the scheduleAtFixedRate() method.

P.S. I don't think it's a good idea to set the priority of the thread inside the task. You should provide Executors with a ThreadFactory that initializes the Thread correctly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!