Let $n$, $T$, and $x_i$ be the number density of hydrogen, the temperature of the gas, and $n_i/n$, where $n_i$ is the number density of the $i$th component of the interstellar medium. We can then write the criteria for thermal equilibrium as
$$n^2\Lambda(n,T,x_i)-n\Gamma(n,T,x_i)\equiv n^2\mathcal{L}=0$$
where $\Lambda$ and $\Gamma$ and the heating and cooling functions, respectively, and $\mathcal{L}$ is defined through those functions and $n$. If the equilibrium is unstable,
$$\left(\frac{\partial\mathcal{L}}{\partial S}\right)<0$$
for entropy $S$. This leads to different instability conditions, termed the isochoric and isobaric instabilities (Field (1965), $\text{Eq } 4a,4b$). These can be determined from the temperature, pressure, and density of the gas (also assuming that the gas can be approximated as an ideal gas).
In general, $\Lambda$ and $\Gamma$ are complicated to determine, although combinations of power-law and exponentially decaying factors may often be sufficient. An example curve that seems to pop up a lot as an example was calculated by Dalgarno & McCray (1972), Figure 2:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/tFGfT.png)
More accurate measurements have been made since then, but the general shape is still applicable. The warm neutral medium occupies the area near the sharp change at around $\sim10,000\text{ K}$, and the cold neutral medium occupies the area in the left of the diagram. Another way to visualize this is on a $\log P/\log n$ diagram like this one (from these slides, annotated from Wolfire et al. (1995)):
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/7lPas.png)
In reality, the two-phase model is an oversimplification, and the ISM has more distinct components. However, the isochoric/isobaric instabilities still limit the range in which clouds can exist in stable equilibria, and explain the dearth of gas in the relevant temperature range.
Let me elaborate on the terms isobaric and isochoric. In thermodynamics, it is sometimes convenient to assume that some thermodynamic variables remain constant in a certain situation. Isothermal processes occur at constant temperature; likewise, isobaric processes occur at constant pressure and isochoric processes occur at constant volume.
The equations for the two instabilities are
$$\left(\frac{\partial\mathcal{L}}{\partial T}\right)_{\rho}<0\tag{Isochoric}$$
$$\left(\frac{\partial\mathcal{L}}{\partial T}\right)_{p}=\left(\frac{\partial\mathcal{L}}{\partial T}\right)_{\rho}-\frac{\rho_0}{T_0}\left(\frac{\partial\mathcal{L}}{\partial\rho}\right)_T<0\tag{Isobaric}$$
In the first, we assume that the cloud is at constant volume, and since the total amount of matter in the system is constant, the (mean) density must also be constant. In the second case, we assume that the cloud is at constant pressure. Perturbations that lead to instabilities thus arise from perturbations of other thermodynamic variables.
As a final note on notation,
$$\left(\frac{\partial\mathcal{L}}{\partial A}\right)_B$$
means that we take the partial derivative of $\mathcal{L}$ with respect to $A$ while keeping $B$ constant. It's a common thermodynamical convention.