sudoku-generator: fix thread-safety issue

Also, doesn't make sense to use ref for a reference-type paramater.
Don't crash if computer has lots of CPUs