Synchronization of Two Ensembles of Atoms