What is the difference between the two ways of running threads in java?

Gods, I just learned java multithreading has a problem
there are two ways to create a thread
the first

myTest a = new myTest(out,"ccc");
    new Thread(a).start();
    new Thread(a).start();
    
  

the second type

 new Thread(new myTest(out,"aa")).start();
 new Thread(new myTest(out,"bb")).start();

what"s the difference between these two creation threads? which one is recommended?

Mar.03,2021

is very different. The first is to create one myTest object, the second is to create two, and the second is to use synchronized (this) to lock Synchronize code blocks.

Menu