NSPR 线程
PRThread *thr;
thr = PR_CreateThread(PR_USER_THREAD,
hello_thread,
NULL,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
#include <prthread.h>
typedef enum PRThreadType {
PR_USER_THREAD,
PR_SYSTEM_THREAD
} PRThreadType;
Enumerators
PR_USER_THREAD
PR_Cleanup blocks until the last thread of type PR_USER_THREAD terminates.
PR_Cleanup 会阻塞等待最后一个PR_USER_THREAD线程才往下执行
PR_SYSTEM_THREAD
NSPR ignores threads of type PR_SYSTEM_THREAD when determining when a call to PR_Cleanup should return.
===========================================================================================================
#include <prthread.h>
typedef enum PRThreadScope {
PR_LOCAL_THREAD,
PR_GLOBAL_THREAD
PR_GLOBAL_BOUND_THREAD
} PRThreadScope;
PR_LOCAL_THREAD 默认用这个
===========================================================================================================
typedef enum PRThreadState {
PR_JOINABLE_THREAD,
PR_UNJOINABLE_THREAD
} PRThreadState;
PR_UNJOINABLE_THREAD 类型分离式,主线程退出,不等待子线程,子线程自己退出释放资源
PR_JOINABLE_THREAD 类型,主线程需要调用PR_JoinThread(thr); 等待线程退出,才会释放资源
===========================================================================================================
优先级默认用:PR_PRIORITY_NORMAL
#include <prthread.h>
typedef enum PRThreadPriority
{
PR_PRIORITY_FIRST = 0,
PR_PRIORITY_LOW = 0,
PR_PRIORITY_NORMAL = 1,
PR_PRIORITY_HIGH = 2,
PR_PRIORITY_URGENT = 3,
PR_PRIORITY_LAST = 3
} PRThreadPriority;
Enumerators
PR_PRIORITY_FIRST
Placeholder.
PR_PRIORITY_LOW
The lowest possible priority. This priority is appropriate for threads that are expected to perform intensive computation.
PR_PRIORITY_NORMAL
The most commonly expected priority.
PR_PRIORITY_HIGH
Slightly higher priority than PR_PRIORITY_NORMAL. This priority is for threads performing work of high urgency but short duration.
PR_PRIORITY_URGENT
Highest priority. Only one thread at a time typically has this priority.
PR_PRIORITY_LAST
Placeholder
PRThread *thr;
thr = PR_CreateThread(PR_USER_THREAD,
hello_thread,
NULL,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
#include <prthread.h>
typedef enum PRThreadType {
PR_USER_THREAD,
PR_SYSTEM_THREAD
} PRThreadType;
Enumerators
PR_USER_THREAD
PR_Cleanup blocks until the last thread of type PR_USER_THREAD terminates.
PR_Cleanup 会阻塞等待最后一个PR_USER_THREAD线程才往下执行
PR_SYSTEM_THREAD
NSPR ignores threads of type PR_SYSTEM_THREAD when determining when a call to PR_Cleanup should return.
===========================================================================================================
#include <prthread.h>
typedef enum PRThreadScope {
PR_LOCAL_THREAD,
PR_GLOBAL_THREAD
PR_GLOBAL_BOUND_THREAD
} PRThreadScope;
PR_LOCAL_THREAD 默认用这个
===========================================================================================================
typedef enum PRThreadState {
PR_JOINABLE_THREAD,
PR_UNJOINABLE_THREAD
} PRThreadState;
PR_UNJOINABLE_THREAD 类型分离式,主线程退出,不等待子线程,子线程自己退出释放资源
PR_JOINABLE_THREAD 类型,主线程需要调用PR_JoinThread(thr); 等待线程退出,才会释放资源
===========================================================================================================
优先级默认用:PR_PRIORITY_NORMAL
#include <prthread.h>
typedef enum PRThreadPriority
{
PR_PRIORITY_FIRST = 0,
PR_PRIORITY_LOW = 0,
PR_PRIORITY_NORMAL = 1,
PR_PRIORITY_HIGH = 2,
PR_PRIORITY_URGENT = 3,
PR_PRIORITY_LAST = 3
} PRThreadPriority;
Enumerators
PR_PRIORITY_FIRST
Placeholder.
PR_PRIORITY_LOW
The lowest possible priority. This priority is appropriate for threads that are expected to perform intensive computation.
PR_PRIORITY_NORMAL
The most commonly expected priority.
PR_PRIORITY_HIGH
Slightly higher priority than PR_PRIORITY_NORMAL. This priority is for threads performing work of high urgency but short duration.
PR_PRIORITY_URGENT
Highest priority. Only one thread at a time typically has this priority.
PR_PRIORITY_LAST
Placeholder