Tuesday, March 3, 2015

scheduleAtFixedRate vs scheduleWithFixedDelay

public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
 long initialDelay,
 long period,
 TimeUnit unit);   
   
      Creates and executes a periodic action that becomes enabled first
      after the given initial delay, and subsequently with the given
      period; that is executions will commence after initialDelay then initialDelay+period, then
      initialDelay + 2 * period, and so on. If any execution of the task
      encounters an exception, subsequent executions are suppressed.
      Otherwise, the task will only terminate via cancellation or
      termination of the executor.  If any execution of this task
      takes longer than its period, then subsequent executions
      may start late, but will not concurrently execute.
     
Argument Parameters   
      1)command : the task to execute
      2)initialDelay : the time to delay first execution
      3)period : the period between successive executions
      4)unit : the time unit of the initialDelay and period parameters
  
Return Value
      ScheduledFuture : representing pending completion of the task, and whose  get() method will 
      throw an exception upon cancellation

 Exceptions Throws
      1) RejectedExecutionException: if the task cannot be scheduled for execution
      2) NullPointerException : if command is null
      3) IllegalArgumentException : if period less than or equal to zero
 
  
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
    long initialDelay,
    long delay,
    TimeUnit unit);  
   
      Creates and executes a periodic action that becomes enabled first
      after the given initial delay, and subsequently with the
      given delay between the termination of one execution and the
      commencement of the next.  If any execution of the task
      encounters an exception, subsequent executions are suppressed.
      Otherwise, the task will only terminate via cancellation or
      termination of the executor.

Argument Parameters
      1)command : the task to execute
      2)initialDelay : the time to delay first execution
      3)delay : the delay between the termination of one execution and the commencement of the nex  
      4)unit : the time unit of the initialDelay and delay parameters
 
Return Value  
     ScheduledFuture : representing pending completion of the task, and whose  get() method will 
     throw an exception upon cancellation
 
Exceptions Throws  
      1) RejectedExecutionException : if the task cannot bescheduled for execution
      2) NullPointerException : if command is null
      3) IllegalArgumentException : if delay less than or equal to zero
     

     
   

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...