I've been using this trick when dealing with boring tasks, to prevent my mind from wandering. If you are on a Mac, this widget can crack the whip on you by chiming at regular intervals: http://www.apple.com/downloads/dashboard/status/prodme.html
Of course, the preferable solution is to find a job where your tasks aren't boring.
Of course, the preferable solution is to find a job where your tasks aren't boring.