attempt at a C pthread version