Preheat the oven to 350 degrees F. Spray a 2 quart, shallow flameproof baking dish with olive oil spray.
Put the potatoes into a large pot and cover with water. Bring to a boil over medium heat. Reduce the heat and simmer until the potatoes are just tender, about 8 minutes. Drain and set aside to cool somewhat.
Put the milk and flour into a large saucepan and whisk until the flour is dissolved. Add the garlic and thyme and heat over a medium-high heat, stirring constantly, until the mixture comes to a boil and is thickened, about 8 minutes. Remove from the heat, discard the thyme sprig, and stir in the salt. Add 1 cup of the cheese and stir until melted.
Arrange half of the potatoes in the baking dish. Pour over half of the cheese sauce. Add the remaining potatoes and top with rest of the sauce. Sprinkle with the remaining cheese and bake for 25 minutes, until bubbling. Put under the broiler and broil on high until the top is browned, about 2 minutes. Serve hot.