Starting and stopping a prog. from another prog.

  • Thread starter andoni.oconchubhair
  • Start date
A

andoni.oconchubhair

Hi,

I have a program (only 100 lines or less) that polls a web-service and
gives me the current status of the service. I want to run this program
on an infinite loop using Thread.sleep() to sleep for 5 mins. after
polling and have some way of starting and stopping it.

Can anyone tell me what I would have to do to achieve this?

I hve thought of having a "lock-file?". Basically just checking for the
existance of a file of a particular name and if it exists then breaking
out of the loop. Another way might be to spawn a thread which listens
for a keystroke using System.in but this would involve running the
program in the user-space only. I couldn't ever log off without
stopping the program.

So I'm sure there's a standard way that is much cleaner??

Thanks in advance for any suggestions,
Andoni.
 
M

Martin Gregorie

Hi,

I have a program (only 100 lines or less) that polls a web-service and
gives me the current status of the service. I want to run this program
on an infinite loop using Thread.sleep() to sleep for 5 mins. after
polling and have some way of starting and stopping it.

Can anyone tell me what I would have to do to achieve this?

I hve thought of having a "lock-file?". Basically just checking for the
existance of a file of a particular name and if it exists then breaking
out of the loop. Another way might be to spawn a thread which listens
for a keystroke using System.in but this would involve running the
program in the user-space only. I couldn't ever log off without
stopping the program.

So I'm sure there's a standard way that is much cleaner??
Listen on a socket for a datagram (UDP packet)? There may be simpler
ways but this way is at least OS agnostic.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top