Both Specificity and Pattern theories are used to help explain how different kinds of pain can occur.
Specificity theories consider pain as an independent sensation with specialised peripheral sensory receptors [nociceptors], which respond to damage and send signals through pathways (along nerve fibres) in the nervous system to target centres in the brain. These brain centres process the signals to produce the experience of pain.
Pattern theories consider that peripheral sensory receptors, responding to touch, warmth and other non-damaging as well as to damaging stimuli, give rise to non-painful or painful experiences as a result of differences in the patterns [in time] of the signals sent through the nervous system.
Nociception v ‘Pain’
Nociception is detection of a noxious stimulus, whereas ‘Pain’ is an 'experience', which is the product of the parts of the brain responsible for mental processing of the noxious stimulus. "Pain occurs in the brain".
The processes that give rise to this painful experience include the noxious stimulation of tissues (peripheral mechanisms) and the unconscious nociceptive processing by the spinal cord and brain (central mechanisms).