此方法是 OMThread 类的构造函数。有关详细信息,请参阅备注部分。
Public
OMThread (int wrapThread);
OMThread(const char* const name = NULL, const long
priority = OMOSThread::DefaultThreadPriority,
const long stackSize = OMOSThread::DefaultStackSize,
const long messageQueueSize =
OMOSThread::DefaultMessageQueueSize,
OMBoolean dynamicMessageQueue = TRUE);
wrapThread
指定是构造新的操作系统线程(这是缺省值,此时 wrapThread = 0),还是将新线程构造为当前线程中的包装器。
可能会使用包装器线程, 例如,在 Rational® Rhapsody® 创建自己的线程以附加到现有 GUI 线程的 GUI 应用程序中。
name
指定线程的名称。缺省值为 NULL。
priority
指定线程的优先级。
DefaultThreadPriority 是在
os.h 中定义的,如下所示:
static const long DefaultThreadPriority;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const
long OMOSThread::DefaultThreadPriority =
THREAD_PRIORITY_NORMAL;
stackSize
指定堆栈的大小。
DefaultStackSize 是在 os.h 中定义的,如下所示:
static const long DefaultStackSize;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const
long OMOSThread::DefaultStackSize = 0;
messageQueueSize
指定消息队列的大小。
DefaultMessageQueueSize 是在
os.h 中定义的,如下所示:
static const
long DefaultMessageQueueSize;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const long OMOSThread::DefaultMessageQueueSize
=
100;
dynamicMessageQueue
指定消息队列是否是动态的。缺省值为 TRUE。
消息队列是 OMThread 的重要构建块。它用于在 Rational Rhapsody 任务(活动类)之间进行任务间通信。OMOSThread 为多个写程序和一个读取器提供了线程安全的不受限消息队列 (FIFO)。此读取器将暂挂消息队列,直到有要处理的消息为止。
请注意不同方法调用之间的以下差别: