Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Starting and stopping a prog. from another prog.

Reply
Thread Tools

Starting and stopping a prog. from another prog.

 
 
andoni.oconchubhair@ie.fid-intl.com
Guest
Posts: n/a
 
      10-22-2006
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.

 
Reply With Quote
 
 
 
 
Martin Gregorie
Guest
Posts: n/a
 
      10-22-2006
http://www.velocityreviews.com/forums/(E-Mail Removed)-intl.com wrote:
> 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.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C++ 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C Programming 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui Python 0 04-27-2009 12:46 PM
Starting and Stopping an Animated GIF Rhino Java 0 11-15-2003 02:48 PM
Starting and stopping a background process Paul Hampton Python 0 07-03-2003 09:58 AM



Advertisments