fix multiple threads connection issue