The difference between these methods is as follows:
Scheduledexecutorservice.Chedule
When calling this method you must define a Runnable
which is your task, the team that the action should be executed and the Timeunit(if and hoars, minutes, etc). This method will execute what we call one-shot action. Your runnable will run only once at set time. (there are overloaded versions that accept Calleables instead of Runnables)
ScheduledExecutorService.scheduleAtAFixedRate
Already on the call of scheduleAtAFixedRate
m[etodo Creates and executes an action - Runnable/Callable
periodic which is activated for the first time after the initial delay given. If any execution of the task of casting an exception, subsequent executions are suppressed, ie are not performed. Otherwise, the task will only end via cancellation or shutidown of the executor
.
Pay attention to this detail:
If any execution of this task takes longer than your period, then subsequent executions may be triggered later, but there will be no execution simultany.
Please take a look at the Javadocs
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html
I believe that
AtFixedRate
either for repetitions, because it implies a frequency (scheduleAtFixedRate = scheduleA_TaxaFixa). "_" was to respect camelCase :D– mutlei
Okay ... Thank you :)
– user2647038
If you have solved the question, let me know and I will turn the comment into a reply.
– mutlei