27. Nio (selector (cancel (event cancellation)))

Nio(selector(cancel(event cancel)))

Step 1: When I listen to the client's connection request, but we don't connect (that is, we don't process it). Then the service falls into a non-blocking (thread keeps running)

 

Step 2: Analyze the select method (the logic of select is that if the event has been processed, then a new event will be needed next time. No new event will still block (become blocked), but if the event is not processed processing, then this select will let the thread continue to process the unprocessed selectorkeys collection (enter the scanning collection loop below)) After the selection, the event is either processed or canel is canceled (event cancellation is key.canel).

 

 

 

Guess you like

Origin blog.csdn.net/logtcm4/article/details/127820855