多个实例的static变量会共享同一块内存区域)
package dubborpc.netty; public class xdsx { public static void main(String[] args) { for(int i=0;i<3;i++) { A d = new A(); d.add(); } } static class A{ private static int a=0; void add(){ a++; System.out.println(a); } } }

只是私有变量的话是不共享的

浙公网安备 33010602011771号