- 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.
推薦閱讀
- Spring 5企業(yè)級開發(fā)實(shí)戰(zhàn)
- Mastering RabbitMQ
- C語言程序設(shè)計(jì)案例教程(第2版)
- SQL Server 2012數(shù)據(jù)庫技術(shù)及應(yīng)用(微課版·第5版)
- Hadoop+Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- C語言課程設(shè)計(jì)
- Visual FoxPro程序設(shè)計(jì)
- SwiftUI極簡開發(fā)
- Java并發(fā)實(shí)現(xiàn)原理:JDK源碼剖析
- Python物理建模初學(xué)者指南(第2版)
- Oracle Database XE 11gR2 Jump Start Guide
- Keil Cx51 V7.0單片機(jī)高級語言編程與μVision2應(yīng)用實(shí)踐
- C語言程序設(shè)計(jì)教程
- ArcPy and ArcGIS(Second Edition)
- Splunk Essentials