本帖最后由 西门吹风 于 2014-6-14 21:43 编辑
应该是一个线程,并且运行的是Thread子类中run 的内容,可以分解成如下代码来解理
- class ThreadTest
- {
- public static void main(String[] args)
- {
- A a=new A();
- B b=new B(a); //相当于new Runnable(new Runnable{}){}
- b.start();
- }
- }
- class A implements Runnable //相当于new Runnable(){}
- {
- public void run()
- {
- System.out.println("1runnable run...");
- }
- }
- class B extends Thread //相当于 new Thread(){}
- {
- B(Runnable b)
- {
- super(b);
- }
- public void run()
- {
- System.out.println("2subThread...run...");
- }
- }
复制代码
|