Irritatingly it doesn't compile without removing the const - because pthread_mutex_lock takes a non-const pointer to the lock, the compiler errors saying it can't convert a const pointer to a non-const pointer.