Kotlin 1 Liner – Get number of available processors / CPU cores from runtime
An example Kotlin code snippet to show you how to get the number of available processors / cores / CPUs in your environment.
Get Available CPU's in Kotlin
Runtime.getRuntime().availableProcessors()
You can also use this method to find number of cores in Java as well.
Output
Output might vary depending on your machine. Here's the number of CPU available in my local machine
8
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.