zoukankan      html  css  js  c++  java
  • 关于线程的两篇文章

    1.Extended Threading: Do More with the Same Thread
    让一个线程完成更多的任务。作者自己写了一个类,拦截System.Threading.Thread,试图让你在不同的线程执行同一个方法成为可能,如果你想执行多次,你不必每次都创建一个新线程来执行该方法,优势在于提高性能并且易于使用,毕竟创建线程的代价还是比较昂贵的。
    作者完成了一个Demo,用自己实现的方案分别对普通线程,线程池实现方式的性能作了比较。

  • Download demo project - 8.3 KB
  • Download source - 16 KB

    2.Smart Thread Pool
    智能线程池。该线程池不同于.net framework提供的线程池,这个线程池完全重新实现,并增加了很多有用的特性。
    The number of threads dynamically changes according to the workload on the threads in the pool.

  • Work items can return a value.
  • A work item can be cancelled if it hasn't been executed yet.
  • The caller thread's context is used when the work item is executed (limited).
  • Usage of minimum number of Win32 event handles, so the handle count of the application won't explode.
  • The caller can wait for multiple or all the work items to complete.
  • Work item can have a PostExecute callback, which is called as soon the work item is completed.
  • The state object, that accompanies the work item, can be disposed automatically.
  • Work item exceptions are sent back to the caller.
  • Work items have priority.
  • Work items group.
  • The caller can suspend the start of a thread pool and work items group.
  • Threads have priority.
查看全文
  • 相关阅读:
    kubernetes 中遇见的一些坑(持续更新)
    Docker网络解决方案-Flannel部署记录
    理解Docker :Docker 网络
    全面剖析Redis Cluster原理和应用
    python发送钉钉机器人脚本
    centos 7 部署LDAP服务
    zabbix 同步ldap帐号脚本
    zabbix TCP 连接数监控
    WebDriver基本操作入门及UI自动化练手页面
    Jmeter使用入门
  • 原文地址:https://www.cnblogs.com/jintan/p/1027867.html
  • Copyright © 2011-2022 走看看