• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

stopping a java program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all
I am preparing a java program running in shell mode, ie. "nohup java MyClass &"
Q1. How can I stop this program? It is running in background mode. (I don't want to use "kill -9" as it is not a health way to stop the program)
Q2. MyClass is a jdbc program. It will keep a jdbc connection when init the program. How can I close all jdbc connection before stopping the program? Is there any java interface / method can be invoked before the program is stopped?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can keep the reference of the class(extending the Thread Class) in a static member variable of same type like:
public class VishalThread extends Thread{
private static VishalThread staticThis = null;
public VishalThread{
//something more graceful
staticThis = this;
}
// Some other sensible methods
public VishalThread getInstance{
return staticThis;}
}
public void stop{
closeTheHangingDBConnections();
super.stop();
}
This trick may not sooth every techi, But will solve your Problem in the Hand............
[ January 19, 2003: Message edited by: Vishal Angrish ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic