Based on the physical background, a new dislocation dynamics model fully incorporating the interaction among differential dislocation segments is developed to simulate 3D dislocation motion in crystals. As the numerical simulation results demonstrate, this new model completely solves the long-standing problem that simulation results are heavily dependent on dislocation-segment lengths in the classical dislocation dynamics theory. The proposed model is applied to simulate the effect of dislocations on the mechanical performance of thin films. The interactions among the dislocation loops, free surface and interfaces are rigorously computed by a decomposition method. This framework can be used to simulate how a surface loop evolves into two threading dislocations and to determine the critical thickness of thin films. Furthermore, the relationship between the film thickness and yield strength is established and compared with the conventional Hall-Petch relation.