threads: limit the number of automatic threads to MAX_AUTO_THREADS