Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Timer & Recursion

807589Sep 9 2008 — edited Sep 10 2008
Can I use Timer in a recursive method that must be executed repeatedly ?

Is this below gonna work?

Recursive method:
public class AppTarefa extends TimerTask {
public void run() {
		if (updater.listenFile()){
			this.process();		
			this.run();
		}
		else{
			this.run();
		}
	}
}
public class App {
	Timer timer;
	
	public App(long delay, long interval){
		timer = new Timer();
		timer.scheduleAtFixedRate(new AppTarefa(), delay, interval);
	}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2008
Added on Sep 9 2008
14 comments
332 views