线程开启(and命名):
// 线程1 Thread myThread = new Thread("threadNo1"){ public void run(){ System.out.println("线程No1"); } }; //线程2 MyThread mt = new MyThread(); //线程3 Thread threadNo3 = new Thread(){ public void run(){ System.out.println("线程No3"); } }; //Thread threadNo4 = new Thread(Task); threadNo3.setName("threadNo3"); //线程1的开启 myThread.start(); //线程2的开启 mt.start(); //线程3的开启 threadNo3.start(); } public static class MyThread extends Thread{ public MyThread() { super("threadNo2"); } public void run(){ System.out.println("线程No2"); } }