| Author |
Scheduling and Checking a Java Programme.
|
singh gaurav
Ranch Hand
Joined: Mar 28, 2010
Posts: 42
|
|
Hi EveryBody,
I have to create two class A, and class B.
1. class A have some methods executed sequentialy within an infinite loop,
2.class B have some logic to check Class A programme is running or not in every 2 minutes, if class A programme is not running then start it,
please suggest me a way to implement both class A & class B.
In abstract
>> How can i check class A is running or not?
>> How can i start class A execution from Class B ?
>> How can i schedule running of Class B application in every 2 mins in a windows environment?
>> How can i implement a infinte java loop ,with out stack over flow.
Hope for your complete reply
Thanks
Gaurav
ctgaurav@gmail.com
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3065
|
|
Take a look at java.util.Timer and java.util.concurrent.ExecutorService.
Honestly, there are often better ways than polling a process every so often. Instead, why don't you wait for the process to notify you of when it's done?
|
 |
singh gaurav
Ranch Hand
Joined: Mar 28, 2010
Posts: 42
|
|
Actually , it is a real time system,
the first class have a infinite loop and continuously executed some method , second class is only care taker of first class and their is no other relation ship like parent -child (inheritance),
So second class (Class B) only ensure that Class A loop and methods are in execution, when class get crashed or its execution stops class B restart Class A.
I also have to ensure that Class A have only one process running ,
no further process is created of class A in any condition.
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3065
|
|
|
Yes, so what's forcing you to poll the process? Why can't you be notified? You need to be more specific in your requirements.
|
 |
 |
|
|
subject: Scheduling and Checking a Java Programme.
|
|
|