aspose file tools*
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
Author

stopping the program

Nagaseshagiri poola
Greenhorn

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

Joined: Oct 29, 2001
Posts: 8866
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stopping the program