5.7. System.Threading
Multithreading allows a process to execute multiple tasks in parallel. Each task is given its own thread of control. For example, in our text query system, we might choose to have each independent subquery executed simultaneously by spawning a thread for the evaluation of each. We could then either pause our controlling program (or main thread) until all the evaluation threads are complete, or perform auxiliary tasks while the executing threads run to completion.
One benefit of multithreading is the potential increase in performance. In a single-threaded program, the time cost of the query evaluation is the sum of the evaluation of each subquery, each executed one after the other in turn. In a multithreaded program, the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access