Each hydrogen atom has one valence electron, but it needs two electrons to be stable. how can both hydrogen atoms each achieve a stable configuration

Each hydrogen atom has one valence electron, but it needs two electrons to be stable. how can both hydrogen atoms each achieve a stable configuration