Using pthread_exit_and_get when the thread is not the IPT and is the last thread

Table 1 describes the actions that are taken when pthread_exit_and_get is issued on a thread that is not the IPT and is the last thread.

Table 1. Using pthread_exit_and_get when the thread is not the IPT and is the last thread
Step Thread 1 (initial pthread-creating task, or IPT) Thread 2 (pthread-created thread)
1 The IPT is in a wait state because of a previous pthread_exit_and_get. pthread_exit_and_get is issued from this thread.
2 Run thread cleanup routines before this thread terminates.
3 Return to pthread-creating task initialization routine that issues pthread_exit_and_get to exit the thread, using the PTEXITTHREAD and PTGETNEWTHREAD option for MWTs or the PTEXITTHREAD option for HWTs. If you want to know when the last thread is terminating so that process termination cleanup can be done first, specify the PTFAILIFLASTTHREAD option. You must then call pthread_exit_and_get again, but this time without the PTFAILIFLASTTHREAD option.
4 A failing return value and reason code from pthread_exit_and_get indicates that this is the last thread.
5 Process the remaining thread and clean up (such as running exits).
6 Call pthread_exit_and_get without the PTFAILIFLASTTHREAD option to terminate the last thread and the process.
7 Clean up any MVS™ resources that may have been obtained STAE/SPIE/storage, after control is returned from pthread_exit_and_get to the pthread-creating task initialization routine.
8 The pthread-creating task initialization routine returns to its caller, terminating the task. The IPT is posted when this task terminates.
9 The IPT gains control after its pthread_exit_and_get and all threads have terminated.
10 Issue the BPX1MPC service to clean up any remaining portions of the process. Control returns from this call after all subtasks created with pthread_create terminate, or until the time to do so has elapsed.
11 The IPT task gains control when control is returned from mvsprocclp and all pthreads for this process and all subtasks of the IPT have terminated.
12 The IPT task is no longer associated with the kernel, and can now return to its caller or to the system.