I used to have big problems with insomnia until I got my sleep hygiene up to snuff. Some tricks that I found helped:
- Slowly count backwards from 100. If a thought intrudes, let it have its moment, then start over. I've found that forcing thoughts to the side tend to make them more persistent.
- Lie still, and start relaxing all the muscles in your body. Start with your little toe, and work your way up. If you can get past your waist and you're still up, something else is going on or you're not fully relaxing the muscles before moving to the next one.
- Read something dull enough to make you bored, but not so dull that you won't bother reading it. For me, organic chem texts worked well, but ymmv.
Good sleep hygiene works best though. Go to bed at roughly the same time each night. Do nothing in bed but sleep and sex. Try to figure out when your circadian cycle is at it's minimum (or reset it using melatonin), and go to bed then. If you're not asleep, or nearly asleep, after a half hour, get up and walk around. Basically you want to make it so that your bed is associated in your mind only with sleep, so that when you lie down in it you will fall asleep faster.
Good luck. There's nothing quite as miserable as chronic sleep dep.