  When a black hole is enclosed in a cavity in asymptotically flat space, an
effective volume can be introduced, and an effective pressure can be further
defined as its conjugate variable. By this means, an extended phase space is
constructed in a cavity, which resembles that in the anti-de Sitter (AdS) space
in many aspects. However, there are still some notable dissimilarities
simultaneously. In this work, the Joule--Thomson (JT) effect of the black
holes, widely discussed in the AdS space as an isenthalpic (constant-mass)
process, is shown to only have cooling region in a cavity. On the contrary, in
a constant-thermal-energy process (the JT-like effect), there is only heating
region in a cavity. Altogether, different from the AdS case, there is no
inversion temperature or inversion curve in a cavity. Our work reveals the
subtle discrepancy between the two different extended phase spaces that is
sensitive to the specific boundary conditions.
