This is sometimes also called "interior monologue".
James Joyce's Ulysses (1922) has one of the most famous examples of the use of stream of consciousness: this is "a passage of interior monologue from the 'Lestrygonian' episode, in which Leopold Bloom saunters through Dublin, observing and musing:
Pineapple rock, lemon platt, butter scotch. A sugar-sticky girl shoveling scoopfuls of creams for a christian brother. Some school great. Bad for their tummies. Lozenge and comfit manufacturer to His Majesty the King. God. Save. Our. Sitting on his throne, sucking red jujubes white."All information taken from Abrams, MH. A Glossary of Literary Terms (6th ed). Orlando: Harcourt Brace College Publishers, 1993. Pg.202-3.