Multithreading / multitasking in general is very useful. You can run multiple things 'simultaneously' while keeping your code nicely seperated (no spaghetti code).I have attached a working example (I compiled with toolchain of Atmel Studio 6).

It runs two threads, prints out something over serial connection and blinks the onboard led. It uses AtomThreads (http://atomthreads.com/). It uses a preemptive schedular (apparently).NOTICE: AtMega2560 has port 7 tied to the on board led instead of port 5. (So change PORTB ^= (1 << 5); to PORTB ^= (1 << 7); for arduino mega).