A barium atom attains a stable electron configuration when it bonds with two non-metallic atoms, like oxygen. Barium is a group 2 element and has two valence electrons. When barium bonds with two non-metallic atoms, it loses its two valence electrons and forms an ionic bond with the non-metallic atoms. This results in a stable electron configuration for the barium atom, as it has the same number of electrons as the noble gas xenon.