If your method is synchronous, you cannot. If it performs asynchronous operations, you should use a flag that each operation checks before starting.
Just like SleepyCod, you can use setInterval / clearInterval, but you can only do this if your method needs to do the same at certain times.
source
share