• 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

stopping the program

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic