在main方法中创建内部类实例时,经常出现以下报错
No enclosing instance of type Single_Producer_Consumer is accessible. Must qualify the allocation with an enclosing instance of type Single_Producer_Consumer (e.g. x.new A() where x is an instance of Single_Producer_Consumer).
经查证,这是因为内部类是动态的(无static修饰),而main方法是static的,所以创建的内部类也要是static的才行,把内部类改为static的就可以了