See: http://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine