黑马一刘昭 发表于 2013-5-26 20:03
对的,调用了父类的构造方法,然后呢?求详解!谢谢。
给你一段代码看看线程的命名和取得线程的名称:- class MyThread implements Runnable
- {
- public void run()
- {
- for(int x=0;x<8;x++)
- {
- System.out.println(Thread.currentThread().getName() + "运行,x =" + x);
- }
- }
- }
- public class Demo
- {
- public static void main(String args[])
- {
- MyThread my = new MyThread();
- new Thread(my,"线程A").start();
- new Thread(my,"线程B").start();
- new Thread(my).start();
- new Thread(my).start();
- new Thread(my).start();
- }
- }
复制代码 |