Sync code using POSIX threads