Creates a new thread.
#include <prthread.h> PRThread* PR_CreateThread( PRThreadType type, void (*start)(void *arg), void *arg, PRThreadPriority priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize);
PR_CreateThread
has the following parameters:
type
PR_USER_THREAD
) or a system thread (PR_SYSTEM_THREAD
).start
arg
priority
scope
PR_LOCAL_THREAD
), global (PR_GLOBAL_THREAD
) or global bound (PR_GLOBAL_BOUND_THREAD
). However, NSPR may override this preference if necessary.state
PR_JOINABLE_THREAD
) or unjoinable (PR_UNJOINABLE_THREAD
).stackSize
PR_CreateThread
chooses the most favorable machine-specific stack size.The function returns one of the following values:
NULL
.If you want the thread to start up waiting for the creator to do something, enter a lock before creating the thread and then have the thread's root function enter and exit the same lock. When you are ready for the thread to run, exit the lock. For more information on locks and thread synchronization, see Introduction to NSPR.
If you want to detect the completion of the created thread, make it joinable. You can then use PR_JoinThread
to synchronize the termination of another thread.