add semaphore in threadmanager