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 Chriss Miller 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
Joined
May 8, 2003
Messages
11
Location
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
I just can't seem to get back my IntelliSense
 
Thanks but How would I run from a Main Method
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top