The electrical behavior of anisotropic BSCCO single crystals is modeled by mutually coupled long Josephson junctions. For the basic fluxon modes with one fluxon per layer, the fluxons will arrange themselves in an anti phase configuration (triangular lattice) because of the mutual repulsion. We are interested in the in-phase modes (square lattice) desired for many potential applications. We consider two mechanisms (i) intrinsic locking by out of phase oscillations at the trailing edge and (ii) locking by an external high-Q resonator with a resonance frequency corresponding to fluxon in-phase motion. The resulting model is a set of coupled nonlinear partial differential equations. By direct numerical simulations we have demonstrated that the qualitative behavior of the combined intrinsic Josephson junction and cavity system can be understood on the basis of general concepts of nonlinear oscillators interacting with a resonator. For some region of the parameter space it is possible to reach the desired synchronous state, making the system potentially suitable for applications. We also consider the system in the flux flow mode under a high magnetic field.