A warning is arguably often a form of threat (and vice versa). The words are close synonyms. A threat, however, is usually used only in connection with an action that has some sort of human (or at least, AI) agency, while a warning often made to alert someone to a mere natural consequence of an action with no human agency (e.g. a warning that an object is hot and could burn you if you touch it).
But, the term "warning", when used in connection with an action that involves human agency, is usually used when the action threatened would be lawful when taken (and often refers to a threat from a third-party rather than the person giving the warning), while the term "threat" is usually used when the action threatened would be unlawful when taken, or if the action, while lawful, is threatened for an improper purposes that amounts to blackmail (e.g. a threat to release legally taken photos showing that someone is having an affair if money is not paid). Also, a threat is generally made by the person who would take the action (or their agent), rather than a disinterested third-party.
Incidentally, a threat to bring a lawsuit, since a proper purposes of a lawsuit is to secure money from someone, is not improper to connect to a demand to pay money.