flag is a static field in DbIpClient. Multiple threads can access it and change its value. synchronize it.