What’s the difference between a threat and a warning?
As it seems to me: Both have the common features of saying that if the other party does something, something bad will happen. Both also likely aim at discouraging doing that thing, perhaps threats even more often than warnings, as some warnings might be just meant as advice to take what the bad consequence into account.
The difference is that in case of a warning, the bad thing is broadcast to happen without the person giving warning choosing to cause it to happen (though sometimes they might mean they’ll be forced to do it, blurring the line); whereas in the case of a threat, the person making the threat states the intention to cause the thing to happen, in order to discourage the other person from doing the first thing.
As such, I think warnings tend to use language of causation and threats that of intention in the first person. Of course, there are veiled threats and what have you where you need to look at more than that to understand it. The real intention is what counts, though that could have multiple levels, as for example with a threat on one level that’s actually on a deeper level intended to provoke the other person rather than stop them.
Talking about this distinction can be relevant when someone confuses the two. For example, based on an actual example I encountered where people were confusing them, suppose someone writes “If you do this, then the group into which I belong will riot.” Which is that? You can’t tell without further context. In the actual case, people were taking it as a threat, but I read more carefully and saw it was a warning, talking about how (other) people were prone to react, but with a side helping of attitude problem, which made it sound like a threat.