During a night’s stay, Bilbo and company got themselves in a bit of trouble when they came across three Trolls had moved down from the Misty Mountains to a cave not far from the road west of Rivendell. The trolls positioned themselves in hopes to trap and eat travelers, but did also settle for livestock or game at other times.
Bilbo and the Dwarves were captured when they approached the Trolls’ cook fire late on a rainy spring evening, and were only saved from death by the intervention of Gandalf, who tricked the Trolls into delaying until dawn: Stone-trolls must be inside by sunrise, because the light turns them to stone. The company found gold in the Trolls’ cave, as well as three Elvish swords, apparently plundered from older hoards: these were kept by Gandalf, Thorin, and Bilbo. Many years later, Aragorn and the Hobbits came across the statuary Trolls as they fled from Weathertop to Rivendell.
William appears to be the leader of the three Trolls in The Hobbit, since it was he who led them to the area Tolkien would later call the Trollshaws. It was William’s pocket from which Bilbo picked a talking purse, resulting in his capture by the Trolls, and it was William who captured Thorin, who had injured Bert and Tom.