pthread_equal() returns 0 if the threads are not the same, and somehow I got that wrong. The worst is that I actually explicitly checked the manpage when I wrote this code.