本帖最后由 红茶2331 于 2013-11-14 14:51 编辑
- class compute implements Runnable
- {
- int i = 0;
- public void run()
- {
- for(int i = 0; i < 10; i++)
- {
- System.out.println("this:"+i);
- }
- }
- }
- class compute1 implements Runnable
- {
- public void run()
- {
- for(int i = 0; i < 10; i++)
- {
- System.out.println(i);
- }
- }
- }
- class threadtest
- {
- public static void main(String[] args)
- {
- compute c = new compute();
- compute1 c1 = new compute1();
-
- Thread t = new Thread(c);
- Thread t1 = new Thread(c1);
- t.start();
- t1.start();
- System.out.println("Hello World!");
- }
- }
复制代码
出现上面这个问题是怎么回事啊?我继承thread类,而不是实现Runnable接口的话就不会出现问题
|