Sigmund Freud’s psychoanalysis understood the mind in psychology as stream of consciousness did in literature. Inspired by the pivotal neurologist, the writing technique captures the loosely structured, sensorial and erratic nature of realistic human thoughts.
The result is challenging to read at first, often featuring off-putting non-sequiturs and huge bulks of unbroken prose. Yet, its association with novels such as Ulysses (James Joyce) and the work of Virginia Woolf make it a notable feature of Modernist literature.
In charting the depths of the human consciousness these writers not only expanded the psychological implications of fiction, but made a radical departure from literary traditions. Sentence structure, syntax, punctuation and grammar take sometimes incongruous forms. They contribute to a non-linear story, and there is a focus on internal observation over external action. This is because they represent the disordered logic of the human mind and challenge the contrived nature of traditional narrative structures.
'Ulysses' achieves this by setting its narrative over the course of a day in the life of Dubliner Leopold Bloom. The mundane, obscene, and philosophical are rolled together into a subconscious bric-a-brac. As a testament to its modernity, the novel alludes heavily to Greek myth but subverts it with its depiction of a colourful and low-brow Dublin.
Then you could take Woolf’s 'To the Lighthouse' for a very different approach. Rather than writing in a first person interior monologue, Woolf opts for a an omnipresent narrator who cycles between the thoughts of various characters inhabiting the same house. In doing so throughout the novel, she tracks the changes of her characters with a psychology clarity, and without needing to rely on overt tension.
It is also pretty telling that for much of the book the dramatic highpoint is a missing brooch.
Simply, stream-of-consciousness is an iconic and contentious device of the Modernist playbook.