fixed pthread issues - attr needs to be defined in every iter of while