Use the Timer class, you can do something like this:
public void timer() {
TimerTask tasknew = new MyTask();
Timer timer = new Timer();
/* scheduling the task, the first argument is the task you will be
performing, the second is the delay, and the last is the period. */
timer.schedule(tasknew, 100, 100);
}
}
This is an example of a class that extends TimerTask and does something.
class MyTask extends TimerTask {
@Override
public void run() {
System.out.println("Hello world from Timer task!");
}
}
For further reading look into
Timer Docs
Timer schedule example