changed pthread use to explicit join