If you are planning to stay in the airport for those hours you don't need a transit visa. If you are planning to move out of the airport and then again enter back you need a transit visa.
If you are transiting in a Thailand airport, you do not need an airport transit visa if: Your connecting flight is in less than 12 hours. Your flight is booked on the same ticket. You do not leave the international airport transit area. You have the necessary documents for your final destination.