Question: Raymond Hettinger has posted a [snippet](http://code.activestate.com/recipes/413137-call-a-functionmethod-x-times-per-second/#c3) where he uses the sched module available in the standard Python library in order to call functions with a specific rate (N times per second). I wonder if there is an equivalent library in Java.

Answer: 
Have a look at java.util.Timer.

You can find an example of use [here](http://www.java2s.com/Code/Java/Development-Class/UsejavautilTimertoscheduleatasktoexecuteonce5secondshavepassed.htm)

You can also consider Quartz, which is much more powerful and can be used in combination
with Spring
Here is an [example](http://www.mkyong.com/spring/spring-quartz-scheduler-example/) 

Here is my equivalent using java.util.Timer of the code snippet you mentionned

```
package perso.tests.timer;

import java.util.Timer;
import java.util.TimerTask;

public class TimerExample  extends TimerTask{

      Timer timer;
      int executionsPerSecond;

      public TimerExample(int executionsPerSecond){
          this.executionsPerSecond = executionsPerSecond;
        timer = new Timer();
        long period = 1000/executionsPerSecond;
        timer.schedule(this, 200, period);
      }

      public void functionToRepeat(){
          System.out.println(executionsPerSecond);
      }
        public void run() {
          functionToRepeat();
        }   
      public static void main(String args[]) {
        System.out.println("About to schedule task.");
        new TimerExample(3);
        new TimerExample(6);
        new TimerExample(9);
        System.out.println("Tasks scheduled.");
      }
}

```
How about using the [java.util.Timer class](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html)?

You can find the example code [here](http://www.roseindia.net/java/example/java/util/CertainAndRepeatTime.shtml)