Stream-of-consciousness is a 20th century term for a method that had in fact been used in earlier times, an attempt to represent something of the process of thinking, instead of setting it out in neat and tidy forms. Thus instead of saying:
“John went to the market square to meet Mary. He was a little worried not to find her there. To pass the time he had a cup of tea. After an hour, he was very worried indeed”.
One might say
“Going along to the market square; Mary must be there; hell she isn’t; wait about for a bit; where is she? have a cup of tea, rotten tea, overpriced tea but does it matter where is she; its been an hour now where is she?”.
Now consider Gollum. His thinking, like that of other characters in The Hobbit and The Lord of the Rings, is described in fairly conventional terms. But his speech, his endless monologue, does have some of the elements of stream-of-consciousness. I’m far from sure whether Tolkien did this deliberately. It could be that he was poking fun at more fashionable forms of literature – as Lewis did in his interesting short story The Shoddy World. Or it could be that he would have denied any such connection, had someone suggested it to him. It’s hard to know.
What I would say is that Tolkien could probably not have created Gollum’s odd monologue unless he had come across “stream of consciousness”. It is Gollum’s mode of speech defines him and makes him the most memorable and original character in both The Hobbit and The Lord of the Rings. That is perhaps more important than Tolkien’s attitude to the literary method (which can make a normal story more or less unintelligible if it is used with too much enthusiasm).