Essentially implemented MapReduce to generated a threaded version that
is correct and doesn't take forever because of tons of locking overhead.
Each thread gets its own results array that it counts into (without
having to worry about conflicts with other threads), and then we add
them all up at the end.
Cleaned things up a bit by having each thread allocate its own partial
results array, thus guaranteeing that no two threads can every content
over the partial results. This did, however, require introducing a lock
so each thread can lock the overall results array when it's time to add
its partial results to that array, but that doesn't appear to have
slowed things down noticeably.