public class OutClass{ //外部类
class InnerClass{...}//内部类
public static void main(String[] args){
InnerClass in = new OutClass().new InnerClass();//定义内部类成员变量
}
}
public class ThreadTest{ public static void main(String[] args) { Thread t=new Thread(new ThreadTest().new Print()); t.start(); } class Print implements Runnable{ @Override public void run() { while(true){ try { Thread.sleep(1000); System.out.println("haha"); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }