The invention relates to a method of thread pool to ensure the continuity of the thread pool needs to maintain a task ID to thread ID Hash table, to manage the tasks assigned to; thread parameters add an attribute parameter: load (nLoad), with the total amount of tasks assigned to each thread identifier no longer; all threads share the same task queue, but in the thread pool each thread a configuration corresponding to the task queue, the thread from the corresponding task queue for new tasks; an individual monitoring thread. The invention has the following advantages: mapping table function 1, the invention uses a new, can guarantee the data input and output of each task when the time continuity of exactly the same; 2, by monitoring the timing start thread can ensure the thread load always tends to be consistent, in order to achieve the best performance of the concurrent.
【技术实现步骤摘要】
本专利技术涉及一种线程池的设计方法,尤其涉及到保证时间连续性的线程池设计方法。
技术介绍
线程池是一种多线程的处理形式。线程池会预先创建若干线程以执行应用程序的 任务,这些线程通常是以队列的形式组织的。一般,线程池需要执行的任务数量要大于线程 池中线程的数量。当某个线程完成了一个任务后,会向任务队列中请求新的任务来执行,直 到任务队列中的任务全部完成。之后线程池中的线程就会被挂起或休眠直到有新的任务到 达。传统的线程池对于执行的任务都会有优先级的区别,对于同一优先级的任务是完 全平等对待的。但完全的平等并不适用于所有的应用场景。例如在实时数据库中,对于所 有的数据都有时间连续性的要求,但由于所有任务在线程池中并行执行,可能后到达的任 务先于之前的任务完成,从而使得线程池输出的数据与输入的数据在时间连续性上发生颠 倒。
技术实现思路
本专利技术所要解决的技术问题是提供一种在实时数据库中处理数据所用线程池的 设计方法。该方法在提供高效的数据处理能力的同时,还可以保证线程池中各线程所处理 数据的时间连续性以及各线程的负载均衡。为解决上述技术问题,本专利技术所述线程池需要维 ...
【技术保护点】
1.一种保证时间连续性的线程池设计方法,其特征在于,所述线程池需要维护一个任务标识到线程ID的Hash映射表,用来对任务的分配进行管理;线程参数增加一个属性参数:负载(nLoad),用以标识各线程所分配的任务总量,该参数以一段时间内该任务到达线程池的频率(nFreq)进行量化,其中时间段(nPeriod)的长度可以根据应用场景进行设置(单位为分钟),量化公式如下:(math)??(mrow)?(mi)nLoad(/mi)?(mo)=(/mo)?(mfrac)?(mrow)?(mi)nPeriod(/mi)?(mo)*(/mo)?(mn)60(/mn)?(/mrow)?(mi ...
【技术特征摘要】
【专利技术属性】
技术研发人员:王非,黄本雄,卢正新,全中伟,邓磊,
申请(专利权)人:华中科技大学,
类型:发明
国别省市:83
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。