今天刚开始学习使用线程,把学习过程与新的记录下来。
创建线程:
非常简单,只需声明她并为其提供线程起始点处的方法委托即可;
终止线程:
使用Abort和Join方法来实现;
Abort方法:用于永久的停止托管线程,一旦线程被终止,它将无法重新启动(有两个重载,带参数的说会返回状态信息,不过我不清楚怎么使用);
Join方法:用于阻止调用线程,直到某个线程终止时为止(有三个重载,带参数的返回值为布尔值);
如果在程序中使用了多线程,辅助线程还未执行完毕,在关闭窗体时必须关闭辅助线程,否则会引发异常;
线程的优先级:
通过线程的Priority属性来获取或设置,共有五个级别;
线程同步:
线程同步是指并发线程高效、有序的访问共享资源所使用的技术,所谓同步,指某一时刻只有一个线程可以访问资源,只有当资源所有者主动放弃时,其他线程才能使用这些资源;
线程同步可以使用Lock、Monitor、Mutex来实现;