Replace multiple threads with a single thread; will retry if connection failed