- 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.
推薦閱讀
- Learning Python Web Penetration Testing
- 現(xiàn)代C++編程:從入門到實(shí)踐
- CockroachDB權(quán)威指南
- Visual Basic程序設(shè)計(jì)教程
- 零基礎(chǔ)學(xué)Python數(shù)據(jù)分析(升級(jí)版)
- Learning Apache Karaf
- PHP+Ajax+jQuery網(wǎng)站開發(fā)項(xiàng)目式教程
- C#開發(fā)案例精粹
- Programming with CodeIgniterMVC
- Arduino電子設(shè)計(jì)實(shí)戰(zhàn)指南:零基礎(chǔ)篇
- MATLAB 2020 GUI程序設(shè)計(jì)從入門到精通
- Python高性能編程(第2版)
- C語言從入門到精通(第5版)
- 開發(fā)者測(cè)試
- Python Business Intelligence Cookbook