Starting and stopping a prog. from another prog.

Discussion in 'Java' started by andoni.oconchubhair@ie.fid-intl.com, Oct 22, 2006.

  1. -intl.com

    -intl.com Guest

    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.
    -intl.com, Oct 22, 2006
    #1
    1. Advertising

  2. -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 |
    Martin Gregorie, Oct 22, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rhino
    Replies:
    0
    Views:
    1,465
    Rhino
    Nov 15, 2003
  2. Paul Hampton
    Replies:
    0
    Views:
    338
    Paul Hampton
    Jul 3, 2003
  3. dfaber
    Replies:
    1
    Views:
    355
    Amit Khemka
    Jul 4, 2006
  4. Replies:
    8
    Views:
    305
    Ian Wilson
    Nov 10, 2006
  5. Junkone
    Replies:
    2
    Views:
    91
    Junkone
    Sep 25, 2008
Loading...

Share This Page