how to check a specific time of day in a program

K

k.sahici

Hi,

What I need to do is to make my program do sth(for instance execute a
function) everyday at 15.00.

Of course I can check the time in a seperate thread, and execute the
function just in time. However, that way seems silly to me. What's
more, it uses the cpu until it's 15.00 and maybe decreases efficiency.

Is there a professional way of waiting for a specific time of day in a
program?

Thanks
 
G

GArlington

Hi,

What I need to do is to make my program do sth(for instance execute a
function) everyday at 15.00.

Of course I can check the time in a seperate thread, and execute the
function just in time. However, that way seems silly to me. What's
more, it uses the cpu until it's 15.00 and maybe decreases efficiency.

Is there a professional way of waiting for a specific time of day in a
program?

Thanks

http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
....
 
N

Nigel Wade

k.sahici said:
Hi,

What I need to do is to make my program do sth(for instance execute a
function) everyday at 15.00.

Sth? What is sth?
Is it perhaps a Sith from Star Wars, and you want to poke his eye out at 15:00?
Of course I can check the time in a seperate thread, and execute the
function just in time. However, that way seems silly to me. What's
more, it uses the cpu until it's 15.00 and maybe decreases efficiency.

Is there a professional way of waiting for a specific time of day in a
program?

java.util.Timer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top