http://en.wikipedia.org/wiki/Preemption_(computing)#Preemptive_multitasking
It's also instructive to know about processor interrupts. Without them, your computer would just be a really expensive box that generates warm air.
http://en.wikipedia.org/wiki/Interrupt
To really understand how it all works you'd need to know more detail about how microprocessors in general work. I'll try to give a brief overview. Some of this info may be quite dated and obsolete (I'm an old fart and haven't delved into assembly programming in quite some time), but the basic principals are still valid.
Your microprocessor contains several registers which hold information about it's current operating state. Among these are pointers to the current instruction of the currently executing program, a pointer to the memory stack of the current program (where variables, function call addresses and suchlike are kept), and other stuff that's relevant only to the currently running program.
Your OS kernel is the primary program running on your computer. It manages running multiple other programs, seemingly simultaneously, by first, storing all the processor state info relevant to it's only operation, then loading in the processor state info for say an application that is running, then the applications instructions run for a while, oblivious to the OS kernel and any other program running.
How control gets switched back to the OS is generally handled through what is called an interrupt. An interrupt is basically a way for something (usually a hardware trigger for something external to the processor itself) to interrupt the main processor's current program. When an interrupt occurs, the processor saves its own state off, and jumps to a small program that has been loaded into memory called an interrupt handler. These interrupt handlers are usually supplied by your OS and loaded into memory when you boot up.
Things that commonly generate processor interrupts are any input device (your keyboard generates one every time you press or release a key) or certain other chips on your motherboard like the UART chip which contains the system clock that ticks off an interrupt every microsecond or so.
One of the interrupt handlers that your OS sets up is tied to the system clock and is designed to interrupt any running program after a short span of time and return control to the main kernel. The kernel can then let another program run for a bit.
This series of program switching happens very fast. Because processors are so much faster, it appears to us to be simultaneous, but it's really just an incredibly complex juggling act going on and most people don't have the slightest clue about the amount of pure genius that went in to making their phone work.
Don't know if this made any sense... It's really late for me.