semaphore: GetThreadCount implementation