Chapter 19 ---> Thread Pooling
Planck🌌🧬🧠🌈 (flowing in the quantum field)
Threads can impact performance when: - linear increasing of context switch cost, threads creation/destruction cost. - nonlinear increasing of cache missing.
To mitigate problem, BCL makes Thread Pool. It can: - reuse threads for different tasks (this is also why task and thread become separate concepts)
Pitfalls: - Thread Pool requires tasks to finish in seconds, otherwise the benefit will be gone. - Can't refer to a task given to it. So can't sync with tasks. That's why we have to use Sleep() to sync.
CPU bound short-term task -> thread pool I/O bound or long-term task -> TPL
Planck🌌🧬🧠🌈对本书的所有笔记 · · · · · ·
-
Events (C# Programming Guide)
Events - C# Programming Guide | Microsoft Docs Events enable a class or object to notif...
-
Thread
by default, a new thread is foreground. OS will terminate all foreground threads before...
-
Chapter 19 ---> Thread Pooling
-
Chapter 19 ---> Asynchronous Tasks
C# 4.0 --> TPL C# 5.0 --> TAP a thread consumes about 1MB virtual memory. So 5000 threa...
-
UI and async
It's easy to do async tasks in UI coding. Just put async work in Task.Run(), and then u...
说明 · · · · · ·
表示其中内容是对原文的摘抄