线程状态及其转换
来源:互联网 发布:adobe云端mac 编辑:程序博客网 时间:2024/04/30 04:12
线程对象使用ThreadState.属性指示线程状态。 Member name Description RunningThe thread has been started, it is not blocked, and there is no pendingThreadAbortException. StopRequestedThe thread is being requested to stop. This is for internal use only. SuspendRequestedThe thread is being requested to suspend. BackgroundThe thread is being executed as a background thread, as opposed to a foreground thread. This state is controlled by setting theThread.IsBackground property. UnstartedThe Thread.Start method has not been invoked on the thread. StoppedThe thread has stopped. WaitSleepJoinThe thread is blocked. This could be the result of calling Thread.Sleep orThread.Join, of requesting a lock — for example, by callingMonitor.Enter orMonitor.Wait — or of waiting on a thread synchronization object such asManualResetEvent. SuspendedThe thread has been suspended. AbortRequestedThe Thread.Abort method has been invoked on the thread, but the thread has not yet received the pendingSystem.Threading.ThreadAbortException that will attempt to terminate it. AbortedThe thread state includes AbortRequested and the thread is now dead, but its state has not yet changed toStopped.
ThreadState是带flag特性的枚举类型对象,因此判断线程当前的状态必须用bitmask,作为一个特例,由于Running状态的bit码是0,因此,需要用如下方式判断线程是否处于运行状态:(myThread.ThreadState & (ThreadState.Stopped | ThreadState.Unstarted)) == 0。
枚举成员如下:
状态转换图如下“
- 线程状态及其转换
- 线程状态及其转换
- 线程的状态及其相互转换
- Java 线程的生命周期及其状态转换
- [Java并发编程]-线程的六种状态及其状态转换
- [Java并发编程]-线程的六种状态及其状态转换
- 线程状态的转换
- 线程状态的转换
- 线程的状态转换
- 线程的状态转换
- 线程状态的转换
- Java线程状态转换
- 线程状态转换
- 线程的状态转换
- 线程的状态转换
- 线程状态转换图
- 线程状态的转换
- 线程状态转换调度
- SVN转移
- VB工程19--百例37--交通红绿灯
- C#常用开源类库收集
- 二叉树知识点
- air创建的子窗口访问父窗体的对象
- 线程状态及其转换
- rake应用
- objective-c基础教程——学习小结
- Understanding
- Ubuntu10.04修复Grub2笔记
- JavaScript对象系统深入剖析-2.函数对象
- 自主创新进展制造世界主要轴承制作强国
- PHP中全局变量的使用global和$GLOBALS[]
- Ubuntu下Rhythmbox乱码的解决办法