Barakados
Barakados

Reputation: 471

schedule an event to happen 10 times a second in java

I am making a game that does something 10 times every second in java. I want to make something that schedules this for me What would be a good resource to look at? EDIT: Must be original java source.... no external software.

Upvotes: 0

Views: 477

Answers (2)

Shashank Kadne
Shashank Kadne

Reputation: 8101

Creating a TimerTask and scheduling it to run after a particular interval should do the trick..

TimerTask timerTask = new TimerTask() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                //your task
            }
        };

schedule it using

new Timer().scheduleAtFixedRate(timerTask, 0, 60*100);

Upvotes: 4

Festus Tamakloe
Festus Tamakloe

Reputation: 11310

Just look at java quartz. it can help you do whatever you want

http://www.mkyong.com/java/quartz-scheduler-example/

Upvotes: 0

Related Questions