Executes given tasks once or over time period