If mass and energy are same thing, then what is the difference open system and closed system? In thermodynamics, closed systems are those from which energy can be exchanged and not mass. But Energy and Mass are the same thing, so does that mean a closed system is the same as an open system (a system in which both mass and energy can be exchanged)
 A: The difference between closed and open system exists in Newtonian, Lorentzian, and general-relativistic thermo-mechanics. In all three theories a closed system can be defined as one that has no particle fluxes. Here are some more details.
In Lorentzian and general relativity, conservation of particle number takes upon the role that conservation of mass has in Newtonian mechanics. There are several distinct particle numbers, but baryon number is probably the most important at the interface between Lorentzian and Newtonian physics: it corresponds to the conservation of the different atomic elements in Newtonian thermo-mechanics. See for example

*

*Misner, Thorne, Wheeler: Gravitation, especially chapter 22.

In fact, the conservation of atomic elements – the main principle of stoichiometry – implies the conservation of mass in Newtonian thermomechanics, since each atom is considered to have a constant mass. In chemistry and in the study of mixtures of different materials, atom-number conservation is often used instead of mass conservation. See for example

*

*Astarita: Thermodynamics: An Advanced Textbook for Chemical Engineers, especially chapter 3;

*Samohýl, Pekar: The Thermodynamics of Linear Fluids and Fluid Mixtures, especially § 4.2.

In Lorentzian and general relativity energy flux carries inertia, and so it is less meaningful to speak of mass conservation. But particle conservation still holds, and this is why we can speak of particle's velocity, which can be non-collinear with momentum (see Eckart below). So in all three theories we can equivalently define (at low energies at least) a closed system as one which doesn't exchange particles, rather than one that doesn't exchange mass. Note that if we consider osmotic phenomena we can also be more specific and consider systems that are closed with respect to some atom species but not to others.

Regarding transfers of energy, in Lorentzian and general relativity strictly speaking we have to consider transfers of energy-momentum, since energy fluxes carry momentum and vice versa. There is an insightful discussion about this in

*

*Eckart: The thermodynamics of irreversible processes. III. Relativistic theory of the simple fluid.


It is also good to always make clear what we mean by "system". There are two main ways to define a system, both in the Newtonian and Lorentzian case: (1) As a body of particles, which has a world-tube in spacetime, be it Newtonian or Lorentzian; the spatial region occupied by the body is determined by the velocity of the particles. (2) As a region of space, arbitrarily defined, and possibly arbitrarily moving and deforming with respect to some reference system.
In the first sense the system is closed by definition or construction, since we are following a given set of particles. In the Newtonian case this also means that there is no exchange of mass. The first definition does not work very well with systems not made of bosons (atoms), such as radiation. In the second definition the system can be closed or open: there can be particles moving in or out of the region of space considered.
A: Ensembles in thermodynamics are defined in terms of quantities that are conserved between the system and the bath. Typically, that means energy $E$ and particle number (mass) $N$. However, this needs to be modified to account for relativity. To say that your system can only gain or lose a particle by exchanging it with the bath is necessarily declaring it to be non-relativistic. Let's go through the three ensembles.

*

*The microcanonical ensemble says that nothing can leave the system. The available microstates are therefore the ones that have the fixed energy $E$. Knowing that each one has probability $e^{-S}$ allows you to derive Boltzmann's formula.

*The canonical ensemble says that energy is the only conserved quantity that can leave the system and it does until the system and bath are at the same temperature. Now the probability of a microstate $e^{-S}$ is most usefully expressed using $F = E - TS$ which is the quantity that will be minimized in equilibrium. Note that other things besides energy can leave the system too as long as they are not conserved. Total velocity in the $x$ direction would be an example.

*If particle number is a conserved quantity, you can also have the grand canonical ensemble. Now particles are exchanged to get a constant chemical potential and $e^{-S}$ involves the grand potential $\Omega = E - TS - \mu N$.

When you have all three, the systems are described as isolated, closed and open respectively. If you can only define the first two ensembles, I don't know whether it's best to call them (isolated, closed), (isolated, open) or (closed, open). However it's worth noting that several applications, such as electron gases, have a microscopic notion of charge. As this is another conserved quantity, you can therefore get a relativistic analogue of the grand canonical ensemble by simply replacing $N$ with $Q$.
A: Energy and mass are not the same thing. Although it is justifiably famous, the equation $E=mc^2$ is actually a simplification of the more general equation $$m^2 c^2 = E^2/c^2 - p^2$$ For $p=0$ the general equation simplifies to the famous one, but the relationship between mass and energy also involves momentum. It is not correct to say that they are the same thing. They are equal (in natural units) when $p=0$, but that does not make them the same thing, particularly since often $p\ne 0$.
However, none of the above is relevant to your question about thermodynamic closed systems. A closed system is one that does not exchange matter with the surroundings, as opposed to one that does not exchange mass. Mass is a property of matter, but matter is more than just mass. A thermodynamically closed system could indeed exchange mass with its surroundings without exchanging matter. This would not make it an open system because mass was exchanged, not matter.
