12. Non-empty set
$$
A=\left\{(x, y) \left\lvert\,\left\{\begin{array}{l}
a x-2 y+8 \geqslant 0, \\
x-y-1 \leqslant 0, \\
2 x+a y-2 \leqslant 0
\end{array}\right\} .\right.\right.
$$

When $(x, y) \in A$, the function $z=y-x$ has both a maximum value and a minimum value, then the range of the real number $a$ is $\qquad$
12. $[2,+\infty)$.

When $a>2$, the region enclosed by the function graph and the Cartesian coordinate system is a triangle, which obviously satisfies the condition;

When $a=2$, the function $z=y-x$ attains its minimum and maximum values on the boundaries $x-y-1=0$ and $2x-2y+8=0$, respectively.