This broke if i was incremented before the new thread read i: for(...; i++) { ldap_pvt_thread_create(,,, &i); ... }