I have a program which run on thread now I have made a GUI interface to run the same. There I have 3 option - Start,Stop,Rerun. I want to start the thread and would like to rerun it if i stop the same. I am trying following code but it stops but not able to rerun it rathermy application do System.exit(0)? WHere I am wrong? Could you pl help me? Code:- ----------
regards, Arun [CODE tags inserted -- PdH] [ February 05, 2002: Message edited by: Peter den Haan ]
Alex Zhang
Ranch Hand
Joined: Apr 19, 2001
Posts: 68
posted
0
Actually, thread cannot be restart once it has been stopped! :roll: So U'd better add a while loop and use the boolean field to control the thread!
Mehul Sanghvi
Ranch Hand
Joined: Feb 04, 2002
Posts: 134
posted
0
Dear Arun, As mentioned earlier you cannot rerun a thread after interrupting it... Your code for interuppt button would remain the same as for your stop and rerun button i tried out the following code which i think may help you out.. CODE:
Regards, Mehul..... [CODE tags inserted -- PdH] [ February 05, 2002: Message edited by: Peter den Haan ]
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
Alternatively, you can rewrite your code as a Runnable. To restart, you run your Runnable with a fresh Thread. - Peter