In Act II, Scene 2 of "Hamlet," Rosencrantz and Guildenstern, who are supposedly friends of Hamlet, have been persuaded by Claudius to try and learn what is behind Hamlet's strange behavior. But, realizing that they have been sent to spy upon him, Hamlet greets them,
What have you, my good friends, deserved at the hands of Fortune, that she sends you to prison hither?(II,ii,232-233)
When they ask him why he thinks Denmark is a prison, Hamlet replies that "thinking makes it so," introducing the motif of appearance vs. reality. Then, when Rosencrantz and Guildenstern attempt to speak in Hamlet's apparently contradictory manner, he further confuses them with more double-talk. Hamlet tells them he cannot reason and asks them why they have come. When they reply "To visit you, my lord; no other occasion" (II,ii,260), Hamlet accuses them of having a confession in their looks, and tells them that he knows the king and queen have sent them. The loyalty of their old friendship wins over their obedience to the king and queen, and they confess.
Out of friendship, then, Hamlet tells them that he is extremely depressed. Everything is "a foul and pestilentcongregation of vapors"(II,ii,287). To cheer him, the schoolmates of Hamlet inform him that a theatrical troop has come to perform and Hamlet forms an idea. With this introduction of the theatrical troop, the motif of appearance vs. reality which has just been witnessed in the behavior of Rosencrantz and Guildenstern and words of Hamlet is again reinforced with the mention of boys playing the women's parts, a timely reference for Shakespeare.