avoid continous blocking from the thread cleanup wait loop
Merge pull request #113 from hastef88/performance_optimization_refactor

avoid continous blocking from the thread cleanup wait loop