Guide to Features
The class
SyncBoolean
is a great tool for simplifying basic inter-thread communication. Threads
in Java can signal each other with the wait-notify mechanism, but there
can be challenges in implementing this safely and robustly...especially
if wait-notify is used over and over in many places. SyncBoolean
can help out with this common situation. It
provides multithread-safe synchronized access to a
boolean value and has great methods like
waitUntilTrue(). With methods like this, one thread can be
waiting for a specific condition while another threads does some task and
then signals this condition by setting the boolean value. Check out the
API documentation for
SyncBoolean
to learn more.
There is a whole subpackage dedicated to First-In-First-Out (FIFO) queues:
com.jthreadkit.fifo.
The class hierarchy is designed to allow for
expansion and alternate implementations. For example,
ObjectFIFO
is an interface specifying the general contract for FIFO queues that
hold generic Object references. There are many ways to
implement this interface with difference performance characteristics.
One implementation,
ArrayObjectFIFO
simply stores the references in a fixed-size array behind the scenes.
To simplify the substitution of different implementations, developers
can write code like this:
ObjectFIFO fifo = new ArrayObjectFIFO();
There is a whole subpackage dedicated to extending Java's Collection API:
com.jthreadkit.collection.
To learn more about the basics of threads and how they work with
Java, consider reading the comprehensive book: Java Thread Programming. This book is a great tutorial for beginners who haven't worked with threads (in any
language).
|