Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy question" Running a program in timed intervals" 1

Status
Not open for further replies.

Kafenated

Programmer
May 8, 2003
11
0
0
IN
I'm new to Threads and for an example to get me going.
Can someone give example code
I would like the method below to run every five minutes.

public void showTime()
{
Date theDate = new Date();
System.out.println("The time is" +theDate);
}
 
Code:
class test extends java.util.TimerTask{

	public test(java.util.Timer t){
		t.schedule(this, 5 * 60 * 1000);
	}
	public void run(){
		showTime();
	}

	public void showTime()
	{
		 Date theDate = new Date();
		 System.out.println("The time is" +theDate);
	}
}

-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top