在.NET框架线程的生命周期 [英] Thread lifecycle in .NET framework

查看:277
本文介绍了在.NET框架线程的生命周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET框架线程的状态解释此链接

最近我看到这张照片在网站和几个问题来到我的脑海里:

  1. 在操作系统线程的生命周期并不完全在.NET框架线程的生命周期一致。有人可以提供一个与.NET框架相匹配的状态中OS资源?

  2. 我们没有在.NET框架所谓的阻止状态。什么将是一个线程的状态,如果它发出的I / O请求?

  3. 已中止状态的目的是什么?当一个线程调用中止()的方法,它会去的 AbortRequested 状态后,线程响应中断请求时,它会去停止状态。那么,什么是已中止状态?

  4. 功能
解决方案

一个线程,如果其执行已被暂停的同步原语,如锁或互斥的一个阻塞。即在给定时刻执行有用的工作的任何线程,根据定义,没有被阻塞的那一刻。

AbortRequested /停止周期使线程有机会执行有序关机,释放所获取的资源并执行其他清理任务。

http://www.albahari.com/threading/

The state of a thread in .NET framework is explained in this link.

I recently saw this picture in a web-site and a couple of questions came to my mind:

  1. The thread lifecycle in the OS is not completely aligned with thread lifecycle in .NET framework. Can someone provide a resource that matches the states in OS with .NET framework?

  2. We don't have a state called Blocked in .NET framework. What will be the state of a thread if it issues an I/O request?

  3. What is the purpose of the Aborted state? When a thread calls the Abort() method, it will go to the AbortRequested state and after the thread responds to abort request, it will go to Stopped state. So what is the function of Aborted state?

解决方案

A thread is blocked if its execution has been suspended by one of the synchronization primitives, such as a lock or a mutex. Any thread that is performing useful work at a given moment is, by definition, not blocked at that moment.

The AbortRequested/Stopped cycle gives the thread an opportunity to perform an orderly shutdown, releasing acquired resources and performing other cleanup tasks.

http://www.albahari.com/threading/

这篇关于在.NET框架线程的生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆