- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 124字
- 2021-08-05 10:46:42
Parallel execution
If parallel execution is assumed, where each thread is executed in one dedicated core, then the execution of isPalindrome() could be around one third of that of the sequential implementation. Each core will filter its 1,000 words without interruption, reducing the total amount of time needed to complete the operation.
It's important to consider creating a reasonable amount of threads for CPU-bound algorithms, making this decision based on the amount of cores of the current device.. This can be leveraged by using Kotlin's CommonPool, which is a pool of threads created to run CPU-bound algorithms.
CommonPool's size is the amount of cores on the machine minus one. So, for example, it will be of size three in a machine with four cores.
推薦閱讀
- C++ Primer習題集(第5版)
- Kubernetes實戰
- 編程卓越之道(卷3):軟件工程化
- 程序員數學:用Python學透線性代數和微積分
- 人人都是網站分析師:從分析師的視角理解網站和解讀數據
- WordPress Plugin Development Cookbook(Second Edition)
- Kinect for Windows SDK Programming Guide
- Apache Mesos Essentials
- 精通網絡視頻核心開發技術
- Hands-On Natural Language Processing with Python
- Linux:Embedded Development
- Mastering Python Design Patterns
- JavaScript程序設計(第2版)
- HoloLens與混合現實開發
- Apache Camel Developer's Cookbook