Instead of hard coding thread number on start up, handle them
dynamically as needed.
The max_jobs variable determines how many workers there may be
running. However, there are also high priority works that should be
executed even though thread count is already maxed. Thus we start a
new worker whenever a high priority work is queued.
As soon as work is finished and there are no more work to do or there
are too many threads to do low priority work, threads will exit.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>