Lock1 and Lock2 are the same objects. That's why you don't have a deadlock.
Integer a = 0;
is equivalent to
Integer a = Integer.valueOf(0);
and Integer.valueOf()
caches all Integer instances between -128 and 127 (by default), as explained in the javadoc.
Use Integer lock1 = new Integer(0)
and Integer lock2 = new Integer(0)
, and you'll get your deadlock back.
Note that using public, shared objects as locks is a very bad idea. And it's an even more bad idea to use non-final variables as locks.