class MyThread011 extends Thread{
public MyThread011(String name){
super(name);
}
public void run(){
System.out.println(Thread.currentThread().getName()+"-->正在 运行 ");
}
}
public class Demo01 {
public static void main(String[] args) {
MyThread011 m1=new MyThread011("线程A");
MyThread011 m2=new MyThread011("线程B");
m1.start();
m2.start();
}
}
==========================================================================================
class MyThread011 implements Runnable{
public void run(){
System.out.println(Thread.currentThread().getName()+"-->正在运行");
}
}
public class Demo01 {
public static void main(String[] args) {
MyThread011 m1=new MyThread011();
Thread t1=new Thread(m1,"线程A");
Thread t2=new Thread(m1,"线程B");
t1.start();
t2.start();
}
}
/*
MyThread011 m1=new MyThread011("线程A");
MyThread011 m2=new MyThread011("线程B");
---------------------------------------
MyThread011 m1=new MyThread011();
Thread t1=new Thread(m1,"线程A");
Thread t2=new Thread(m1,"线程B");
主要是这两段话,得到的线程A和线程B是一样的吗? 这两段话,得出来的线程A和线程B,到底有什么区别?
|