Mutex 1.0
is an advanced thread handling class.

Mutex was not written by Canadian Mind Products, but by
Jeffrey D. Smith, jeffrey_smith@earthlink.net
of Farsight_systems.com. He is fully responsible for
its content.

Most of these sources are nearly verbatim or
enhanced versions described in the "Java
Threads" book by Oaks & Wong, O'Reilly publisher.
However, I added my copyright due to my style
changes, and there is attribution in the
commentary where appropriate.

ReadWriteLock has been enhanced to support
upgrading a read-only lock to read-write.

The EventQueue classes and interfaces are
my own design for sending EventQueueNode
elements between threads. There are methods
to wait until a queue is empty or non-empty.
The nodes are doubly-linked with sentinel
(fake) nodes marking the head and tail of
the list (EventQueue) for constant-time
insertion and removal of a node.

I use this package in my commercial product.
It works well mediating TCP/IP message packets
(subclasses of EventQueueNode). Threads wait
on either a SocketChannel or on the EventQueue,
depending on which way the data is going. The
TCP/IP component is not included. I have a
TCP/IP "read" thread and another "write" thread.
These threads talk to two EventQueue structures
that have Java threads "on the other side" that
manage the Runnable payloads of the EventQueueNode
elements.

An EventQueueNode has a Runnable object as its
"payload". A thread pulls off a node, extracts
the Runnable object and calls its run() method.
This design separates the queue management from
the details of the what the node means.

You can run JavaDoc on the source to see
the commentary and how classes work
together.

If you enhance/fix the code, I would
appreciate receiving a copy of the updated
source.

-30-