threads: add sysconf based number of CPUs detection