The kind of thoughts that keep a person from falling asleep can arise in either half of the brain
Ttherefore, a person being prevented from sleeping solely by such thoughts would be able to fall asleep by closing the eyes and counting sheep, because this activity fully occupies the left half of the brain with counting and the right half of the brain with imagining sheep, thereby excluding the sleep-preventing thoughts
Thoughts of sheep would induce sleep in the person whenever those thoughts arose.