Recap

Here are the ways to reap the benefits of multicore processors:

  • We have to divide the application into multiple tasks that can be run concurrently.

  • We should choose at least as many threads as the number of cores, provided the problem is large enough to benefit from those many threads.

  • For computationally intensive applications, we should limit the number of threads to the number of cores.

  • For IO-intense applications, the time spent blocking influences the number of threads we’d create.

  • Estimate the number of threads using the following formula:

     
    Number of threads = Number of Available Cores / (1 - Blocking Coefficient)

    where 0 blocking coefficient < 1.

  • We should slice the problem into several parts so there is enough work for cores and ...

Get Programming Concurrency on the JVM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.