consensual hallucination
A Dream of Wessex, by Christopher Priest (Books 2008, 9)
This is the motherlode of all brains-in-jars/life-is-a-computer-simulation-type stories. Gibson's and the Wachowskis' Matrixes can both trace their origins back to here - or at least, they should be able to. I'm not aware of anything older than this that quite deals with this idea.
At Maiden Castle in Dorchester in the near future (of the time the book was written; it’s now our near past) a scientific research project has been under way for several years. It involves ‘projection’, in which the particpants, their bodies unconscious, enter into a shared, simulated fantasy world. This consensus hallucination was intended to examine a possible future, with a view to suggesting answers to some of the problems of today.
But one of the participants has been stuck in the projection for two years (when the normal period is measured in weeks or a few months at the most); the trustees are getting worried about the costs; and a new participant is about to arrive and change everything.
It is excellent, and (of course) leaves you wondering how many levels of fantasy there are to reality - both the book’s, and ours.