Use MVar to manage connection for thread-safety.