provide the thread safe for generate connection