pthread version works