pr_jointhread.rst (1488B)
1 PR_JoinThread 2 ============= 3 4 Blocks the calling thread until a specified thread terminates. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <prthread.h> 13 14 PRStatus PR_JoinThread(PRThread *thread); 15 16 17 Parameter 18 ~~~~~~~~~ 19 20 :ref:`PR_JoinThread` has the following parameter: 21 22 ``thread`` 23 A valid identifier for the thread that is to be joined. 24 25 26 Returns 27 ~~~~~~~ 28 29 The function returns one of the following values: 30 31 - If successful, ``PR_SUCCESS`` 32 - If unsuccessful--for example, if no joinable thread can be found that 33 corresponds to the specified target thread, or if the target thread 34 is unjoinable--``PR_FAILURE``. 35 36 37 Description 38 ----------- 39 40 :ref:`PR_JoinThread` is used to synchronize the termination of a thread. 41 The function is synchronous in that it blocks the calling thread until 42 the target thread is in a joinable state. :ref:`PR_JoinThread` returns to 43 the caller only after the target thread returns from its root function. 44 45 :ref:`PR_JoinThread` must not be called until after :ref:`PR_CreateThread` has 46 returned. If :ref:`PR_JoinThread` is not called on the same thread as 47 :ref:`PR_CreateThread`, then it is the caller's responsibility to ensure 48 that :ref:`PR_CreateThread` has completed. 49 50 Several threads cannot wait for the same thread to complete. One of the 51 calling threads operates successfully, and the others terminate with the 52 error ``PR_FAILURE``. 53 54 The calling thread is not blocked if the target thread has already 55 terminated. 56 57 :ref:`PR_JoinThread` is interruptible.