The Gemara on Amud Aleph questions why the Cohen Godol should be sequestered from his wife seven days before the Yom Kippur service? The Gemara answers that since there is only one Cohen Godol (and one back-up), we worry his wife might show signs of having become niddah right after intercourse. There would then be concern that perhaps she was niddah during intercourse. When such a situation occurs and there was sexual relations, there is an impurity transferred onto the husband that lasts seven days. The Cohen Godol would then be invalidated to perform the service.
There is a machlokes Rashi and Tosafos here about the limits of psychological security, which is a machlokes Rashi and Tosafos Leshitassam in Kiddushin 29a, which I will explain.
Rashi learns here that the Cohen Godol that the Gemara suggested that the Cohen Godol could co-habit with his wife in the Lishkas Parhedrin during the seven days prior to Yom Kippur. Tosafos raises an objection that someone who has seminal emissions, sexual or inadvertently while sleeping, is forbidden to be on the entire Temple Mount. Therefore Tosafos suggests a different approach, which is more clearly articulated by Ritva. Let the Cohen Godol enter the underground chambers (known as mechilos whose entrance faced outside) or areas that are near the Temple Mount, but are not consecrated with the same holiness, and therefore are permitted for sexual activity. The Ritva adds a key point. This was not merely a question as to what he could do, but even what he ought to do, in order to leave him in a state of relative sexual satisfaction so that there would be no concern that on the eve of Yom Kippur he experienced a nocturnal seminal emission. (If the Cohen Godol has a seminal emission, it would take immersion in the mikvah and waiting until sunset to become ritually pure. Thus, if he had a seminal emission Yom Kippur night, he would not be able to perform the Yom Kippur service.)
What becomes clear here is that Tosafos and Ritva understand only one way of achieving psychological security, and that being in a concrete manner. That is, the Cohen Godol should have a sexual outlet prior to Yom Kippur eve to avoid a seminal emission. Yet, it is unlikely that Rashi held that the temple mount was permitted for sexual activity, since we find no such position articulated. Therefore, what could Rashi have had in mind? We must conclude that Rashi held that the idea of having his wife present with him provided enough psychological security that he would not be in danger of a seminal emission on the night of Yom Kippur. This security was achieved not by actually engaging in sexual intercourse because it was not permitted on the Temple Mount, rather he felt secure and sexually satisfied because if he really needed to be sexual he could do so by exiting the grounds, even though he didn’t actually leave.
This exact psychological machlokes occurs in Kiddushin 29a when the Gemara discusses the difference between the Palestinian young torah scholars and the Babylonian young torah scholars. One group would marry first, and then study Torah. The other group would study Torah and then marry. The Gemara itself is ambiguous as to which group did what, but the two concerns that are being weighed against another are: Marrying earlier, which would protect from lustful sinful thoughts, versus the burden of supporting a wife and family which would dilute the intensity and focus on Torah study.
Rashi Learned that the Babylonian scholars would get married first, then go off to Israel to study Torah. Tosafos (ibid) objects to Rashi, wondering how living apart from their wives would in any way reduce lust and sinful thoughts. After all, their wives were in a different country! Tosafos therefore reverses the scenario, interpreting the Gemara as saying that the Palestinian scholars got married first and were able to still study Torah without too much interruption due to the relative standard of living and access to wealth in Israel, while the Babylonian scholars deferred marriage and went to Israel to study.
The point is, that Rashi once again understands psychological security and its ability to limit lust and sinful thoughts in a broader manner than Tosafos. The fact that they had wives, even if they were far away in Babylonia, allowed the Torah scholars the security to mitigate their lust. That is, they knew if they really needed to, they could return back to Babylonia, although they might not have done so. So we see, Rashi is consistent in both areas of the Talmud, allowing for a broader kind of psychological security that can relieve lustful and desirous states without relying on concrete sexual outlets.
When it comes to responsibly managing our own sexual urges, we see two approaches, which in a practical sense, can be equally valid depending on the person’s emotional state. Sometimes a person can only satisfy and manage his or her libidinous urges with an actual sexual outlet, while at other times, it may be sufficient to rely on psychological potential to be sexual, possibly other forms of emotional intimacy, without actually having to engage in sexuality.