• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stopping the program

 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my program i am initializing a program and which has both initialization n deInitialization.
when "Start" button is clicked i initialize the program and has to run continously and i dont use any threads concept. So when the button "Stop" is clicked it has to stop the program.
the code looks like this.
if(actionCmd.equalsIgnoreCase("Scan Channels")){ startScan();
}
if(actionCmd.equalsIgnoreCase("Save Channels")){
stopScan();
}
public void startScan(){
// will initialise other program and runs continously.
}
public void stopScan(){
// will diInitialises the program.
}
but it is not happening its running continously. so please help how can i stop my program. do i need to use the concept of threads.
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using the GUI event thread to do your execution. That's what calls the actionPerformed() method when you click the start button. Since the thread is busy doing your processing it can't get around to handling your stop button. You need to have another thread to handle your processing and have the start and stop buttons invoke notify() and wait() respectively. The Java Tutorial: Threads should help you out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic