I have a problem trying to stop a process during execution.
My process consists of a csv parser. My intention was to create a start button that will run the csv parser, and a stop the button to halt the csv parser. I used a function system.exit(), the whole program closes. What I want to do is just to interrupt the csv function. When I use the thread.sleep(), the stop button hangs there and there’s no way to press the start button. Many thanks!
private void stopActionPerformed(java.awt.event.ActionEvent evt) {
st = 0;
if (st = 0)
{ }
}
private void startActionPerformed(java.awt.event.ActionEvent evt) {
st =1;
if (st = 1){
Start1 test = new Start1();
test.sbutton();}
Use Thread.sleep(Time)
But remember to run your csv parser in a separate Thread. If you are having only one thread then your entire application hangs.
For example: