What this means and an example
implementation.
"If" Thread #1 wants to add items to be processed by
Thread #2, normally Thread #1 would have to synchronize
on a Thread lock (A.K.A. Monitor) in order
to safely add
items to.
ie:
Thread #1 -> Lock Thread #2 Process List.
-> add item
to Thread #2 Process List.
-> Notify
Thread #1
This has what can be a Severe caveat.
If Thread #1 has to add numerous items,
It has to continuously interrupt Thread #2.
With this impementation of list multiplexing,
Thread #1 has only to synchronized on the AddList, and
tis leaves the process list free to continue
processing without being interrupted at all.
(not counting context switching)
When Thread #2 has finished its processing it
checks the AddList and in "One" method call can add
the whole add list to the process list.
An exact implementation:
The NIO server has a thread to accept incoming
connections. It also has a Thread to handle Output IO.
If multiple nodes connect at the same time the server accept Thread
would have to interrupt and block the Ouput IO Thread 1 for each
connection (n).
In its implementation of interleaved multiplexed lists the server
accept Thread simply accrues incoming connections
onto the "Incoming Add list",
and then the IO process Thread
can synchronize on this list when it is finished its current
IO output/input iteration and add (n) nodes in one operation
IO is never blocked by incoming/outgoing node connections.
There are lists for connecting, disconnecting,
input, output, external connections, and timing.
|