There are many parts of an aircraft that passengers don't get to see. The cockpit is probably the most obvious one, but most long-haul aircraft have another area that passengers aren't allowed to access.
Often located above the business class and economy cabins, special crew rest areas provide an area away from the demands of passengers to allow crew on long flights to get some sleep.
Pilots have sleeping quarters above business class, so they are closer to the cockpit, while cabin crew are usually above economy.
They get changed into pyjamas before getting in bed, leaving their uniforms hanging outside the curtained off bunk so they can be located if needed in an emergency, and so their uniform doesn't get creased.
Each crew member gets around four hours of rest time on flights over around 12 hours, and the breaks are taken in shifts to make sure there's always crew available to assist passengers with their needs.
Just that little bit of rest makes for a much happier cabin crew and in-turn a much better flight.