Used ReentrantLocks instead of intrinsic locks for gc locks

This avoids a deep recursion to lock all them, which sometimes resulted
in a stack overflow