No enclosing instance of type A is accessible. Must qualify t找不到哪里错了。。。

package com.a.thread.thread4;

public class A
{

class Inner
{
    public synchronized void a(int time) throws InterruptedException
    {

        Thread.sleep(time);

        System.out.println("a:  " + time);
    }

    public synchronized void b(int time) throws InterruptedException
    {

        Thread.sleep(time);

        System.out.println("b:  " + time);
    }
}

class MyThread extends Thread
{
    private Inner i;

    private int time;

    public MyThread(Inner i, int time)
    {
        this.i = i;
        this.time = time;
    }

    public void run()
    {
        try
        {
            i.a(time);
            i.b(time);
        }
        catch (InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

public static void main(String[] args)
{
    Inner i = new A().new Inner();
    MyThread m = new MyThread(i, 3000);
    new MyThread(i, 3000).start();
    new MyThread(i, 1000).start();
}

}

在MyThread m = new MyThread(i, 3000);
new MyThread(i, 3000).start();
new MyThread(i, 1000).start();
都错了。。。
y?

查看全部
sean1203
sean1203
2010/07/16 09:50
  • it技术
  • 互联网问答
  • IT行业问题
  • 编程语言问答
  • 计算机技术
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复