count number of threads