Overview

The aim of JEgg is to simplify the construction of multithreaded applications in Java by providing a development paradigm that enables the application code to be written without using java.lang.Thread or use of the synchronized keyword.

To that end, JEgg active objects, called "eggs" here, don't communicate using synchronous method invocations. Instead, they communicate using messages, ordinary Java objects with no special pedigree (but likely to be application specific), which are both sent and received asynchronously. Moreover, the sender doesn't need a reference to the receiver in order to send a message since each egg can publish its "message port" in a built-in registry from which other eggs can retrieve it.

Message delivery is treated like an event in the receiver, which must implement specific handlers for the types of messages that it expects to receive. The JEgg framework uses reflection to polymorphically deliver a message to the receiver's most specific handler (based on the message's concrete type).

Messages are dispatched to each egg independently of any other egg, and the framework ensures that only one message at a time is delivered to the egg.

The assignment of physical threads to eggs is independent of any egg's implementation. By default, all eggs execute on the same thread, but if a particular egg blocks for long periods while handling its messages, it is trivial for the application to assign that egg to a different physical thread without requiring any changes to the egg's implementation.

Because of the extremely low coupling between eggs, each egg is naturally cohesive, and the message-based communication with "one-message-at-a-time" semantics eliminates thread synchronization issues (deadlocks, race conditions, etc). The end result is that a JEgg-based applications can be written with less, more focused, code and achieve a higher level of robustness.

Some developers may initially find the message-based inter-object communication disconcerting, but it is easy to adjust to, and the JEgg framework provides facilities to make it easy. Developers with finite state machine development experience may even find the paradigm natural from the start.

In JEgg, active objects are referred to as "eggs" to highlight the featureless aspect of each egg's interface. From the outside, all eggs look alike!