# ExecutorService

ExecutorService is a Java interface for managing task execution, termination, and Futures for tracking asynchronous tasks.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## C++ futures part 3: The mental model for std::async

DevFeed: [C++ futures part 3: The mental model for std::async](<https://devfeed.tech/articles/c-futures-part-3-the-mental-model-for-std-async-88253.md>)

Original publisher: [Read original article](<https://devblogs.microsoft.com/oldnewthing/20261014-00/?p=112774/>)

Author: Raymond Chen

Published: 2026-10-14T14:00:00Z

Content type: article

Language: en

Sources: [Raymond Chen](<https://devfeed.tech/sources/raymond-chen.md>)

Topics: [ExecutorService](<https://devfeed.tech/topics/executorservice.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [old-new-thing](<https://devfeed.tech/tags/old-new-thing.md>)

### AI overview

The post explains the mental model for C++ std::async, comparing when a callable runs and whether it runs on the requesting thread or its own thread. It notes that the C++ standard does not allow immediate execution on the same thread through this mechanism, and that when launch options are combined, an implementation may honor one and ignore the other.

### Source excerpt

Doing things later in different ways. The post C++ futures part 3: The mental model for <CODE>std::async</CODE> appeared first on The Old New Thing.

## Reduce, Reuse & Recycle your thread pools ♻

DevFeed: [Reduce, Reuse & Recycle your thread pools ♻](<https://devfeed.tech/articles/reduce-reuse-recycle-your-thread-pools-25909.md>)

Original publisher: [Read original article](<https://chao2zhang.medium.com/reduce-reuse-recycle-your-thread-pools-%EF%B8%8F-81e2f54d8a1d?source=rss-d19045640fe------2>)

Author: Chao Zhang

Published: 2021-12-20T18:26:36Z

Content type: tutorial

Language: en

Sources: [Chao Zhang](<https://devfeed.tech/sources/stories-by-chao-zhang-on-medium.md>)

Topics: [threadpools](<https://devfeed.tech/topics/threadpools.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [mobile-app-performance](<https://devfeed.tech/topics/mobile-app-performance.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [ExecutorService](<https://devfeed.tech/topics/executorservice.md>), [Library](<https://devfeed.tech/topics/library.md>), [scheduling](<https://devfeed.tech/topics/scheduling.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [app-development](<https://devfeed.tech/tags/app-development.md>), [app-performance](<https://devfeed.tech/tags/app-performance.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [costs](<https://devfeed.tech/tags/costs.md>), [health](<https://devfeed.tech/tags/health.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [manage](<https://devfeed.tech/tags/manage.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-pressure](<https://devfeed.tech/tags/memory-pressure.md>), [okhttp](<https://devfeed.tech/tags/okhttp.md>), [overhead](<https://devfeed.tech/tags/overhead.md>), [performance](<https://devfeed.tech/tags/performance.md>), [pool](<https://devfeed.tech/tags/pool.md>), [reduce](<https://devfeed.tech/tags/reduce.md>), [resources](<https://devfeed.tech/tags/resources.md>), [reuse](<https://devfeed.tech/tags/reuse.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [schedules](<https://devfeed.tech/tags/schedules.md>), [thread](<https://devfeed.tech/tags/thread.md>), [thread-pools](<https://devfeed.tech/tags/thread-pools.md>)

### AI overview

Android thread pools can be consolidated to reduce thread count and resource overhead, but merging changes concurrency behavior and requires auditing every library. The sample app routes OkHttp (including Retrofit and Coil), WorkManager, and coroutines through a shared ThreadPoolExecutor; WorkManager needs on-demand initialization and a custom Configuration.Provider, while coroutine dispatchers must be injectable and converted from the executor. The sample's active threads fell from 35 to 19. A separate A/B test in a large app measured a 2% reduction in 90th-percentile cold launch time, a context-specific result. Pool defaults differ, and missed configuration can leave extra pools active; the author recommends naming and auditing threads, validating changes with A/B tests, and guarding against regressions.

### Source excerpt

Photo: Héctor J. Rivas from Unsplash Real-world applications today are mostly multi-threaded. This means developers should be mindful of managing the concurrency of their applications. Mastering the threading can help boost an app's performance. On the other hand, using concurrency without fully understanding it could lead to problems that negatively impact the app's health. For Android applications, every thread is mapped to a system-level thread at runtime. Each thread costs a minimum of 64k of memory on Android, If we always create a thread for any new asynchronous task, we will create memory pressure on the app. The app performance may suffer because spawning up new threads and context switching among threads are both taking up time and resources. If a thread is referenced even if it is not active, it will be kept in memory and can't be cleaned up by the garbage collector. Thread pools can help us manage concurrency more efficiently. ThreadPoolExecutor creates a pool of worker threads and schedules the tasks for them to execute. It can grow the pool size to meet the demand as new tasks arrive, and it can shrink the pool when threads are idle and no longer need to be kept alive. Thread pool, therefore, improves the app performance by reducing the per-task overhead and controls the resource usage by bounding the resources. Thread pool seems the solution to our concurrency headache, and many libraries have adopted this technique, such as OkHttp and AndroidX WorkManager. Each library maintains its own thread pool by default. When we include these libraries in our application, since each library spins up new threads by itself without the awareness of other thread pools, we come full circle. Hundreds of threads exist in our application because those libraries do not know each other. In this story, we are going to walk through an example of configuring libraries to share a common thread pool. We will also summarize the benefits and costs of managing thread pools, as it

## Dining Philosophers in Java 8

DevFeed: [Dining Philosophers in Java 8](<https://devfeed.tech/articles/dining-philosophers-in-java-8-32218.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2016/12/29/dining-philosophers-in-java-8/>)

Author: Bruce Eckel

Published: 2016-12-29T00:00:00Z

Content type: article

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Deadlock](<https://devfeed.tech/topics/deadlock.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Java](<https://devfeed.tech/topics/java.md>), [locking](<https://devfeed.tech/topics/locking.md>), [async](<https://devfeed.tech/topics/async.md>), [ExecutorService](<https://devfeed.tech/topics/executorservice.md>)

Tags: [arrays](<https://devfeed.tech/tags/arrays.md>), [chopsticks](<https://devfeed.tech/tags/chopsticks.md>), [class](<https://devfeed.tech/tags/class.md>), [collection](<https://devfeed.tech/tags/collection.md>), [collections](<https://devfeed.tech/tags/collections.md>), [completablefuture](<https://devfeed.tech/tags/completablefuture.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [deadlock](<https://devfeed.tech/tags/deadlock.md>), [deadlocks](<https://devfeed.tech/tags/deadlocks.md>), [debug](<https://devfeed.tech/tags/debug.md>), [dijkstra](<https://devfeed.tech/tags/dijkstra.md>), [executor](<https://devfeed.tech/tags/executor.md>), [foreach](<https://devfeed.tech/tags/foreach.md>), [forks](<https://devfeed.tech/tags/forks.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>), [tasks](<https://devfeed.tech/tags/tasks.md>)

### AI overview

The Java example shows how philosophers can deadlock when each takes a right chopstick and then waits for the left, creating circular wait. A `StickHolder` uses a size-one `BlockingQueue` to ensure only one philosopher can hold a chopstick at a time; philosophers block in `take()` until it is returned. The program may appear to run correctly before deadlocking, and adding thinking time or philosophers makes deadlock less likely without eliminating the underlying risk. The example breaks circular wait by reversing the chopstick order for one philosopher, so that philosopher takes the left stick first. The text notes that deadlock can also be prevented by breaking any of its four necessary conditions, and that avoiding shared resources is easiest when feasible.

### Source excerpt

Because tasks can become blocked, it's possible for one task to get stuck waiting for another task, which in turn waits for another task, and so on, until the chain leads back to a task waiting on the first one. You get a continuous loop of tasks waiting on each other, and no one can move. This is called deadlock.1 If you try running a program and it deadlocks right away, you can immediately track down the bug.