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

Table 1 describes the actions that are taken when pthread_exit_and_get is issued on a thread that is the IPT and is not the last thread. The IPT is placed in wait state until all other pthreads in this process terminate.

Table 1. Using pthread_exit_and_get when the thread is the IPT and not the last thread
Step Thread 1 (initial pthread-creating task, or IPT) Thread 2 (pthread-created thread)
1 A request to exit the pthread was issued.
2 Run thread cleanup routines before terminating this thread.
3 To terminate the thread, issue the pthread_exit_and_get service with the PTEXITTHREAD option. To determine when the last thread has terminated so that process termination cleanup can be done first, use the pthread_exit_and_get service with the PTFAILIFLASTTHREAD option. Then repeat the pthread_exit_and_get service, but without the PTFAILIFLASTTHREAD option.
4 The IPT is now in a wait state until the process terminates.
5 A return from pthread_exit_and_get indicates that all other pthreads for the process have terminated.
6 The mvsprocclp service is issued to clean up any remaining portions of the process. Control returns from this call after all subtasks that were created with pthread_create terminate, or until time to do so has elapsed.
7 The IPT task gains control after the mvsprocclp call. All pthreads for this process and all subtasks of the IPT have terminated.
8 The IPT task is no longer associated to the kernel, and can now return to the caller or to the system.