added comments and a shared stack to hold the available threads