Community Server-->多线程管理池
来源:互联网 发布:淘宝宽屏代码 编辑:程序博客网 时间:2024/05/19 18:41
这部分包括3部分:
CommunityComponents.Semaphore 检测类。
CommunityComponents.ManagedThreadPool 线程管理池。
CommunityComponents.WaitingCallback 等待回调的对象
1.1 检测类
此类主要监控系统资源中多线程的锁定以及释放。
P():锁定当前对象,并阻塞当前线程为无限等待时间,并置变量count――。
V():锁定当前对象,并通知等待队列中的线程锁定对象状态的更改,以唤醒其开始工作,并置变量count++。
Count:记录当前队列等待回调的对象的个数。
1.2 线程管理池
常量定义_maxWorkerThreads默认为5,构造函数时从配置文件中取得最大工作线程数。
static Queue _waitingCallbacks;当前队列等待回调的对象
static Semaphore _workerThreadNeeded;用符号表示一个工作线程将用于处理此对象工作,同时可能存在并发多个工作线程。
static ArrayList _workerThreads;当前线程池中的所有线程。
static int _inUseThreads;当前使用的线程数。
static ManagedThreadPool():初始化最大线程数,并开启最大线程数相应的线程,并置之为后台线程处理,每台线程委托相应的任务ProcessQueuedItems;
ProcessQueuedItems():从队列waitingCallbacks中取出一对象执行回调同时置当前使用的线程数inUseThreads加一,当此方法执行完毕时执行finally方法置当前使用的线程数inUseThreads减一。
QueueUserWorkItem() :将WaitCallback工作对象放入队列Queue中,并置workerThreadNeeded调用V()方法。
EmptyQueue():清除所有waitingCallbacks中的对象并重置workerThreadNeeded为0。
1.3 等待回调的对象
此类表示线程池线程执行回调时返回当前对象。- Community Server-->多线程管理池
- Community Server
- community server
- Community Server专题一:概述Community Server
- Community Server专题一:概述Community Server
- Community Server专题一:概述Community Server
- Community Server学习资料
- Community Server的问题
- Community server 杂笔
- Professional Community Server
- Professional Community Server Themes
- Community Server-->权限处理
- Community Server-->HTTP处理
- Community Server-->工作任务
- Community Server-->搜索处理
- Community Server-->缓存
- Community Server系列之九:CS2中的用户管理1(MemberRole)
- Community Server专题(转贴)
- HashMap及泛型实例(瞎搞的)
- 十六招成为大型软件项目的开发英雄
- Community Server-->搜索处理
- Community Server-->串行化处理
- 50个能够满足所有需要的Python模块
- Community Server-->多线程管理池
- Community Server-->缓存
- PKU 1861 最小生成树之KK算法
- Community Server-->多语言版本
- 此dos非彼dos
- Community Server-->异常日志处理
- setsockopt()用法
- 服务管理器 小结
- C中的#