Nio (multi-thread optimization (worker association))
The first step: Create a worker object (here we should only create a limited worker, instead of creating a worker for one connection (it is almost ok with the number of cpu cores)), so we should put it outside the while
! ! ! Note: And the worker below us is a member inner class and the one above us is a static method. Static methods cannot directly use the member inner class (methods/variables (private variables are all available)), so we give the member inner class Add static to become a static member inner class.
Step 2: Register the copied sc channel to worder (output it before and after reading the data)
Also output here
Changed to a selector for better recognition
client:
Test: (There is a problem, the client enters data, but the server does not execute it)