added thread check to speed up epcc task waiting