本帖最后由 曾林魁 于 2013-5-30 12:22 编辑
- class ThreadDemo1 extends Thread
- {
- void ThreadDemo1(){}
- void ThreadDemo1(String name)
- {
- super(name);
- }
- public void run()
- {
- for (int i = 0;i<=100 ;i++ )
- {
- System.out.println(this.getName()+"this is a instance of thread");
- }
-
- }
- public static void main(String[] args)
- {
- ThreadDemo1 t1= new ThreadDemo1("线程1");
- ThreadDemo1 t2= new ThreadDemo1("线程2");
- //ThreadDemo1 t1= new ThreadDemo1();
- //ThreadDemo1 t2= new ThreadDemo1();
- t1.start();
- t2.start();
- System.out.println("Hello World!");
- }
- }
复制代码 编译提醒无法调用构造器怎么回事? |