• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to run and control an endless thread?

 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a collection (6 or 7) of individual applications that are supposed to run forever. There main task is to keep a number of databases synchronous. Currently these applications cannot be controlled or monitored from outside.
The idea is to write a small webapp to control them, which would mean something like starting, stopping and getting a status.
I see two possibilities for this, running all those applications in different threads inside the webapp, or running them all together in a seperate rmi-server and use rmi-calls in the webapp.
What are the pro's and contra's of both solutions and which one would be preferable?
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally I'd implement the whole thing as a servlet in which your monitoring/management functions run as threads that are started from the init() method.
Requests to the servlets can then set a few globals to indicate requested actions, which can be polled from these threads so they know what to do with a slight delay.
The other option entails basically doing the same thing but instead of having the functions implemented inside the servlet and running as threads you have a single thread running that passes on given commands based on RMI requests which are sent in by threads in your main monitoring program in order to poll the servlet regularly.
More complicated, more errorprone, but potentially more flexible (for example if the web app needs to run on different hardware it may be the only way).
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One nice thing about using a servlet is that it is then easy to check on performance statistics, recent error messages, etc. from anywhere with a browser connection.
Bill
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may not meet your needs at all ... but I recently used FireDaemon to run a Java program as a Windows NT service. Now I can use NT features to start, stop, auto start at reboot, auto restart after failure, etc.
http://www.firedaemon.com/
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic