question about stop /start multi-threads in java

i have a start button on my GUI
one start button, one stop button

when start button is clicked, it performs a new thread()
when stop button is clicked, it kills all threads

now the application runs fine when click on start button once, it does not run again if click on it after first click.

how could i make it run repeatedly?
IkelcaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Make sure you're calling Thread.start and not Thread.run
0
IkelcaAuthor Commented:
i did call thread start()
0
CEHJCommented:
Can you post your code?
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

IkelcaAuthor Commented:

class mainTest
{
.............block of code.....


private void startBtnActionPerformed(java.awt.event.ActionEvent evt) {
new Thread(){
        public void run()
        {  
            t1.start()  //another class extended Thread
            t2.start() // another class extended Thread
         }
}
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
                public void run() {    
                new mainFrame().setVisible(true); 
            }   
        } );
        
           
    }
 public test1 t1=new test1();
    public test2 t2=new test2();
    public test3 t3=new test3();
}

Open in new window

0
IkelcaAuthor Commented:
the code is very lengthy, so i can only put parts of it  here

forgot to put start() there
class mainTest
{
.............block of code.....


private void startBtnActionPerformed(java.awt.event.ActionEvent evt) {
new Thread(){
        public void run()
        {  
            t1.start()  //another class extended Thread
            t2.start() // another class extended Thread
         }
}.start();
}
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
                public void run() {    
                new mainFrame().setVisible(true); 
            }   
        } );
        
           
    }
 public test1 t1=new test1();
    public test2 t2=new test2();
    public test3 t3=new test3();
}

Open in new window

0
IkelcaAuthor Commented:
i think what happens is t1 t2 or t3 one of them is not stopped or still on?
im not sure.....
0
IkelcaAuthor Commented:
in addition, t1 t2 are two lengthy thread which run about 5 mins
0
Mick BarryJava DeveloperCommented:
>             t1.start()  //another class extended Thread
>            t2.start() // another class extended Thread

you need to create new threads each time
you cannot start the same thread multiple times

            t1 = new test1()
            t1.start()  //another class extended Thread
            t2 = new test2();
            t2.start() // another class extended Thread
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.