Actress类应该是静态类么。。

来源:2-3 Java线程-隋唐演义实战开发---演员简介

Carey_Wu

2016-02-26 22:01

为什么我的new Thread(new Actress(), "Ms.Runnable");这句上的new Actress()爆出这个下面这个错误。但我把Actress类前面加成static就好了,老师的Actress不是静态类但却没有报错。。 No enclosing instance of type Actor is accessible. Must qualify the allocation with an enclosing instance of type Actor (e.g. x.new A() where x is an instance of Actor).

写回答 关注

2回答

  • 慕盖茨0926574
    2016-02-28 10:09:45
    已采纳

    先搞清楚static 的作用,就是共享,如果一个类要被声明为static的,只有一种情况,就是静态内部类

    Carey_...

    非常感谢!

    2016-03-29 11:28:28

    共 1 条回复 >

  • aigougou
    2016-03-24 12:37:29

    我也是加了一个STATIC 才能运行 不然就一直报错

深入浅出Java多线程

带你一起深入浅出多线程,掌握基础,展望进阶路线

186067 学习 · 502 问题

查看课程

相似问题