My definition is as follows,
Gambling has a negative expected value. You know how casinos make money.
Investing has a positive expected value. If the stock price is lower than the corporate value, you invest and wait. Of course, it is possible to miscalculate the expected value due to information asymmetry. That's risk.
Gambling is not risk, it's gambling.