Multiple locks - Behind the scene
问题 class A { Object lock1 = new Object(); Object lock2 = new Object(); List<Integer> list1 = new ArrayList<>(); List<Integer> list2 = new ArrayList<>(); void insert1() { synchronized (lock1) { list1.add(5); } } void insert2() { synchronized (lock2) { list2.add(5); } } void firing() { for (int i = 0; i < 1000000; i++) { insert1(); insert2(); } } Above is an part of code, here thread t1 calls firing() and t2 calls firing(). I used lock1 and lock2 so that both thread will not wait to release the