It's not a secret anymore!
The moose likes Java in General and the fly likes stopping the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "stopping the program" Watch "stopping the program" New topic

stopping the program

Nagaseshagiri poola

Joined: Oct 18, 2003
Posts: 25
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")){
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

Joined: Oct 29, 2001
Posts: 9189

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.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: stopping the program
It's not a secret anymore!