Monitoring Changes in Execution State
The Threading package has two mechanisms for monitoring execution state changes:
A pair of runnable
wait functions that you can use to make the calling thread wait until the runnable enters an execution state of interest.
A callback mechanism that allows you to register one or more functors as
callbacks to be invoked when the corresponding runnable enters a targeted execution state.
If you must reliably detect runnable state changes in your application, then use one of these two mechanisms. They are described in the following sections.