State Railway of Thailand (SRT) has a 4000-km network covering most of the country, from Chiang Mai in the north all the way to (and beyond) the Malaysian border in the south. Compared to buses, most trains are relatively slow and prone to delays, but safer. You can pick up fruits, snacks and cooked food from hawkers at most stations.
Point-to-point fares depend on the type (speed) of the train and the class of the carriage. There are three main classes:
First class (chan neung) 2-berth sleeping compartments with individually regulated air conditioning are available on some trains, but prices are sometimes matched by budget airfares.
Second class (chan song) is a good compromise, costing about the same as 1st class buses and with a comparable level of comfort. Some 2nd class trains are air-con, others aren't; air-con costs a little more.
Second class sleeper berths are comfortable and good value, with the narrower upper bunks costing a little less than the wider lower bunks. Food and WCs are basic. 2nd class Express Railcar trains have reclining seats and refreshments are included in the fare; unlike all other Thai passenger trains, they can match buses for speed, but cannot carry bicycles.
Third class (chan saam) is the cheapest way to travel in Thailand, with virtually nominal fares, and can be great fun. Sometimes packed with tuk-tuk drivers heading home with a sack of rice and a bottle of cheap whisky for company, as a farang (foreigner of European ancestry) you're guaranteed to be the center of attention - quite enjoyable in small doses, but 10 hours of this might be a bit much. Some 3rd class trains have wooden seats, others are upholstered; some services can be pre-booked, others cannot; refreshments are available from hawkers who roam the aisles.
Pre-booking is recommended, especially for sleeper berths. Tickets on all main lines can be purchased online at SRT's official E-Stars site; however, only a quota of 10% of seats can be sold online, so it will often show trains as full when, in reality, there's still plenty of space (Tip: if you get an error during registration - just remove any special characters from your registration data; you can always edit your profile later). Alternatively, many travel agencies can book tickets for a service fee (50-200 baht/ticket), or you can reserve with SRT directly by e-mail at passenger-ser@railway.co.th for a 200 baht/booking surcharge.