Add basic thread synchronization