• Post Reply Bookmark Topic Watch Topic
  • New Topic

stopping a java program  RSS feed

 
glogin glogin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Vishal Angrish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!