Multithreading

Based on my results in #44, I put this together.

It moves some code around, mostly to pull all the iterations into a central place. It also puts locks on critical sections and adds a command line switch (-num-threads).

Even if this is merged, I propose keeping it turned off by default for a while and encouraging people to test it.

Looking forward to feedback.