pthread example using conditional variables