Praise be to Allah The Lord of the Worlds.
Masturbation is forbidden. Its alternative is to strive to get married and overcome all barriers by means of hard work and satisfaction with what is little. In order for the young man to preserve himself from immorality, it is permissible that he takes an interest-free loan to get married.
However, if he is unable to get married, he should make a great deal of fast since this is the advice of the Prophet (PBUH). Abdullah (b. Mas'ud) (Allah be pleased with him) reported that Allah's Messenger (PBUH) said to us: "0 young men, those among you who can support a wife should marry, for it restrains eyes (from casting evil glances) and preserves one from immorality; but he who cannot afford It should observe fast for it is a means of controlling the sexual desire." {Related by Bukhari & Muslim}.
In addition, young men should avoid whatever causes them to commit this habit and provoke their desire, such as looking at forbidden things, mingling with women and surrendering to promiscuous thoughts. They should also avoid staying alone and having foods that stimulate such desire. Moreover, they should ask Allah The Almighty to Help them safeguard their chastity and Facilitate marriage for them; of course, after they adopt means to reach that end.
This is along with working out, indulging in useful business and busying minds with that which is beneficial along with acquainting themselves with memorizing and understanding. And Allah Knows Best.