• System.Threading中Thread和Task区别


    A task is something you want doing.

    A thread is one of possibly many workers who perform that task.

    In .NET 4.0 terms,a Task represents an asynchronous operation.Thread(s) are used to complete that operation by breaking the work up into chunks and assigning to seperate threads.

    Intel TBB and the OpenMP API manage task  scheduling through work stealing.In work stealing,each thread in the thread pool maintains a local task pool that is organized as a deque (double-ended queue). A thread uses its own task pool like a stack,pushing new tasks that it spawns onto the top of this stack.When a thread finishes executing a task,it  first tries to pop a task from the top of its local stack.The task on the top of the task is the newest and therefore most likely to access data that is hot in its data cache.If there are no tasks in its local task pool,however,it attempts to steal work from another thread (the victim).When stealing,a thread uses the victim's deque like a queue so that it steals the oldest task from the victim's deque.For recursive algorithms,these older tasks are nodes that are high in the task tree and therefore are large chunks of work,often work that is not hot in the victim's data cache.Therefore,work stealing is an effective mechanism for balancing load while maintaining cache locality.

    The thread pool and the work-stealing scheduler that distributes work across the threads are hidden from developers when a tasking library is used.Therefore,tasks provide a high-level abstraction that lets users think about the logical parallelism in their application without worrying about managing the parallelism.The load balancing provided  by work-stealing and the low creation and destruction costs for tasks make task-based parallelism an effective solution for most applications.

  • 相关阅读:
    Jmeter_远程启动 I
    jmeter(九)逻辑控制器
    Mysql innodb 间隙锁 (转)
    MySQL- InnoDB锁机制
    Innodb间隙锁,细节讲解(转)
    性能测试:压测中TPS上不去的几种原因分析(就是思路要说清楚)
    Redis性能调优
    Redis基础
    VMThread占CPU高基本上是JVM在频繁GC导致,原因基本上是冰法下短时间内创建了大量对象堆积造成频繁GC。
    关于Hibernate二级缓存第三方插件EHCache缓存
  • 原文地址:https://www.cnblogs.com/hongjiumu/p/2713411.html
Copyright © 2020-2023  润新知