Use proper thread synchronization #9