First off, how can I have a program running two different pieces of code simultaneously?

Secondly, how could I (if possible) tell the program to run the two different pieces of code on different processors or cores if more than one core exists?

Thanks.