java创建线程报错问题

图片说明public class test {
/**
* @param args
*/
public static void main(String[] args) {
new a();
}

 public  class a extends Thread{

     public void run(){
         new Login();        
     }
 }

}

为什么 a 这个类必须是static 才能new a()

这个是静态类语法限制等,
1. 把a单独放到另一个包中去
2. 把a申明为静态类

http://stackoverflow.com/questions/15331846/non-static-variable-this-cannot-be-referenced-from-a-static-context

还有一种方法就是通过外层类实例来访问

                        test t = new test();
            a x = t.new a();
            x.run ();