added semi-correct pthread implementation