@@ -0,0 +1,1032 @@
+package com.gooker.javajvm.sync;%0A%0A/**%0A * desc : SyncAddTest.java%0A *%0A * @author : mozi  on 2017/7/24 10:18.%0A */%0Apublic class SyncAddTest %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        for (int i = 0; i %3C 1000; i++) %7B%0A//            new Thread(new SyncAddRunnable(1, 2)).start();%0A//            new Thread(new SyncAddRunnable(2, 1)).start();%0A%0A//            new Thread(new SyncAddRunnable(-128, 127)).start();%0A//            new Thread(new SyncAddRunnable(127, -128)).start();%0A%0A            new Thread(new SyncAddRunnable(-129, 128)).start();%0A            new Thread(new SyncAddRunnable(128, -129)).start();%0A        %7D%0A    %7D%0A%0A    static class SyncAddRunnable implements Runnable %7B%0A        int a, b;%0A%0A        public SyncAddRunnable(int a, int b) %7B%0A            this.a = a;%0A            this.b = b;%0A        %7D%0A%0A        public void run() %7B%0A            synchronized (Integer.valueOf(a)) %7B%0A                synchronized (Integer.valueOf(b)) %7B%0A                    System.out.println(a + b);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

add Sync Add test .