[SPARK-3106] Fix the race condition issue about Connection and ConnectionManager

We use non blocking IO.
Please take a look at ConnectionManager and Connection classes in detail to get better understanding of the codebase; there are a lot of resources online about how to use nio in non blocking mode in a multithreaded application.