Thread states:
STOPPED
No state transitions are possible without the main thread initiating them. Sent messages are handled "offline." Depending on thread implementation, the offline command handler may:
- Alter private Thread state directly and acknowledge a command directly by producing an ack message on its output queue.
- Enqueue the command on the input queue and transition the Thread to
STARTING
.
STARTING
The Thread may transition to RUNNING
at any time. Sent messages are enqueued on the input queue and no other action is taken.
RUNNING
The Thread may transition to STOPPING
at any time. Sent messages are enqueued on the input queue and the thread is prompted to consume its queue at its next opportunity.
STOPPING
The Thread must transition to STOPPED
shortly.
Any messages enqueued on the input queue in the time between the last queue consumption and the (atomic) transition to STOPPING
will be shunted to the dead letter office.
Attempting to send new messages:
- Joins the Thread, transitioning it to
STOPPED
. - Re-sends anything in the dead letter office and the new messages.
-
What if a message that would cause the Thread to start is stored in the dead letter office, and no other messages arrive to prompt the Thread to join and process it?*
-
Can a message enter the queue while the Thread is
STARTING
, but not be included it the initial batch of handled messages or trigger a wake-up? -
Can the Thread be prompted to wake after it's prompted to begin
STOPPING
?