At some point during your inbound flight to Thailand, you will be given arrival and departure cards to fill out, which will be attached to one another. These cards are simple enough to fill out, requiring your name, passport number, flight you are arriving on and flight you be departing on etc. You should have the information, as well as a pen on hand as you will be best served to fill in the form on the plane, and not at the front of the passport control queues where you will be wasting more than your own time.
If you do try to fill the cards out at the passport officer’s desk they will ask you to stand out and rejoin the back of the line once your form is completed. This is a tedious task for all involved, so be prepared and make your arrival as smooth as possible.
Keeping the departure slip will be convenient for when you leave, as forgetting it will see you stand in line to get a new one with time needed to fill it in again.