• 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 keep Java VM Alive

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys ,
i am writing some Java program that requires to run for ever
unless the user wants to stop it.
How can i stop java VM from terminating ???
Can u people give me some idea of Keep-Alive Mechanism or
something ??

Regards,
Bhaswar
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an endless loop?

if the main thread is not terminating, the vm will neither. furthermore a seperate watchdog thread might monitor your business-process(es) and restart them if required.

...not so advanced...

jan
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of application is this? A desktop app will not terminate automatically as long as there are open windows.
 
bhaswar goswami
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a Servichost where i can host different User Seervices.
SO want to keep the host alive for ever.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what ServiceHost or UserService mean to you. "server" is nicely defined as a process that waits for connections and/or requests from clients. A server usually runs in some kind of loop. Does your server look something like:

If so, it should loop until you set the "running flag" to false somehow. Does that sound like it meets your needs?
[ April 05, 2006: Message edited by: Stan James ]
 
bhaswar goswami
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not exactly...
It's a kind of Service host where u can host defferent Services
like -
say one Mailing Service , Data gathering Service etc.

but if i want to stop the Host i would say [ctrl+c] AS I STOP
Jboss app-server . The catch is how can i sense that the user
has pressed in the Java code.

The Service Host wil run from the DOS command prompt.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not answering the Ctrl-C question partly because I don't know but mostly because I wouldn't encourage users to do that if I could help it, which explains why I never bothered to figure it out.

Let's try to not do it again ...

Any better?
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic