Well, the simplest way is to do it with software. A program lile
Fruity Loops would be good for that. Or if you want to loop things in real time, something like Abelton Live or the Mobius VST looper (for Windows) would be worth trying.
Or you could get a drum machine and a standalone looper that syncs to the drum machine through MIDI.