Static analysis for enforcing intra-thread consistent locks in the migration of a legacy system