- Added proper check for thread availability