The paper presents two-dimensional simulations of the locking of tearing modes to resistive walls in tokamaks during the early phase of density limit disruptions. Two different trigger mechanisms for wall locking have been considered. In the scenario believed to be most relevant for density limit disruptions, the m=2/n=l tearing mode becomes unstable while still rotating and develops a rotating magnetic island. When the mode lock occurs, wall stabilization is lost and the magnetic island grows, leading to disruption. Factors determining the increase in island size resulting from the mode locking are discussed. Another trigger mechanism is slowing down of the rotation through changes in the equilibrium, which decreases the wall stabilization and makes the tearing mode linearly unstable.