In a heavy saucepan, heat butter over medium heat. Add the shallots and garlic; cook, stirring until fragrant and soft, about 3 minutes. Add the mushrooms and cook, stirring, until wilted and their liquid is evaporated, 4 to 5 minutes. Add the rice, and cook, stirring constantly, until the grains are opaque, about 1 minutes. Stir in the thyme, salt and pepper.