Hate crimes are despicable and a sign of stupidity. If you don't agree with an opinion or a lifestyle, it's not really harming your individual way of life, is it? The existence of homosexuals does not threaten the existence of heterosexuals. The judge in this case may have decided to make an example of this man, and maybe it will stop others from harming people they don't like.
The case of one man being sent to prison for the act of throwing boiling water on a gay couple is a singular incident. It will not change the minds of those who are steeped in prejudice. The change of attitudes can not be based on the criminal system. It will be a long process for some people to learn acceptance for the gay population.
The premise that a long prison sentence will deter people from hate crimes is based on, in my opinion, a false belief that the perpetrators are rational. Having negative views toward gays does not lead most people to actively harm them. Those who do transform their feelings of hate into violent action are already prone toward violence and will not be affected by consequences.
No, the 40-year prison sentence for the man who threw boiling water on a gay couple will not likely deter future hate crimes. Hate crimes occur when an individual is moved by intense emotion or disgust. They're usually crimes of the moment and are not planned out. Individuals are not likely to think out the consequences of their actions ahead of time.