Make connection state machine thread safe.