more comments
let the main thread help the unfinished workers
documentation; better var names
no effective changes
bugfix: wrong integer type

but it does not really matter
fixed a dead loop when n_threads==1