This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Scheduling and Checking a Java Programme.  RSS feed

 
singh gaurav
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Saloon Keeper
Posts: 7716
141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Saloon Keeper
Posts: 7716
141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!