Depends on what it is that you want to stop the execution of. You might be able to use a thread with a while loop and sleep delay. You can
bind a key to the component and use it to interrupt the thread. Or you might be able to use
wait and
notify.
Have a look at
Lesson: Concurrency for some ideas.