Java实例化内部类

有时需要在一个class内声明n个内部类,实例化内部类使用如下代码

 

trial("Synch", CALL_COUNT, new Immutable().new Synch());

 

public class Immutable { private static final long CALL_COUNT = 1000000000L; public static void main(String[] args){ trial("Synch", CALL_COUNT, new Immutable().new Synch()); trial("NotSynch", CALL_COUNT, new Immutable().new NotSynch()); } private static void trial(String msg,long count,Object obj){ System.out.println(msg + ":BEGIN"); long start_time = System.currentTimeMillis(); for(long i = 0;i

你可能感兴趣的:(Java)