used thread synchronization to prevent sample polling from running ahead of responses