C# 线程基础

1  线程是进程中的一个执行流 线程

2 线程是一个能够单独操做的活动3d

3 线程建立和经常使用方法orm

  a  建立   blog

   Thread  th=new Thread(Method);进程

 b 常见方法it

  th.start() //启动线程io

  th.Abort()//终止线程方法

  Thread.Sleep(n)//休眠线程 (中止n毫秒后继续执行)im

  th.Suspened()//挂起线程,在调用resume以后,若线程已挂起则无做用db

  th.Resume()//恢复线程//恢复挂掉的线程对正在运行的线程无做用

  th.Interrupt()//终止线程 用于终止 处于sleep 或者 wait  join 以后后的线程

 c 线程常见属性

d  线程状态类 ThreadState

常常用来存储线程状态

例如 Threadstate tmp = th.ThreadState;

ThreadState 是 Thread的一个属性 

e 线程 优先级  

ThreadPriority   ,一般值为

 // 摘要:
        //     能够将 System.Threading.Thread 安排在具备任何其余优先级的线程以后。
        Lowest = 0,
        //
        // 摘要:
        //     能够将 System.Threading.Thread 安排在具备 Normal 优先级的线程以后,在具备 Lowest 优先级的线程以前。
        BelowNormal = 1,
        //
        // 摘要:
        //     能够将 System.Threading.Thread 安排在具备 AboveNormal 优先级的线程以后,在具备 BelowNormal 优先级的线程以前。默认状况下,线程具备
        //     Normal 优先级。
        Normal = 2,
        //
        // 摘要:
        //     能够将 System.Threading.Thread 安排在具备 Highest 优先级的线程以后,在具备 Normal 优先级的线程以前。
        AboveNormal = 3,
        //
        // 摘要:
        //     能够将 System.Threading.Thread 安排在具备任何其余优先级的线程以前。
        Highest = 4,

 //设置线程优先级

Thread.Priority = ThreadPriority.X ;.//X为线程优先级 

相关文章
相关标签/搜索