Detecting Thread Termination

Let’s learn how threads can detect if the receiver of a message has been terminated.

OwnerTerminated exception

This exception is thrown if when receiving a message from the owner the owner has been terminated. The intermediate owner thread below simply exits after sending two messages to its worker. This causes an OwnerTerminated exception to be thrown at the worker thread:

Get hands-on with 1000+ tech skills courses.