Commit e988673
committed
docs(concurrency): add detailed notes on Executors Framework in Java
WHAT was added:
- Comprehensive overview of Executors Framework (introduced in Java 5, part of java.util.concurrent).
- Clear explanation of WHY Executors are used:
• Efficient thread pooling (reuse vs manual creation).
• Reduced thread lifecycle overhead.
• Built-in pooling strategies for different workloads.
• Automatic handling of thread lifecycle.
- Key components highlighted:
• Executor → base interface with execute(Runnable).
• ExecutorService → advanced thread pool management (submit, shutdown, etc.).
• Executors → factory class for creating various thread pools.
• Future → async result handling.
- Detailed tables describing thread pool types:
• FixedThreadPool → bounded concurrency.
• CachedThreadPool → dynamic scaling, reuses idle threads.
• SingleThreadExecutor → sequential task execution.
• ScheduledThreadPool → supports delayed and periodic tasks.
- Advantages section included in two styles:
• Bullet list with emojis (easy scan).
• Extended explanation of performance, scalability, flexibility, and resource management.
WHY this matters:
- Provides a theoretical foundation for Java concurrency and thread pooling.
- Serves as a quick reference for choosing the right Executor type for different scenarios.
- Reinforces best practices (thread reuse > manual thread creation).
HINTS / NEXT STEPS:
- Always call shutdown() or shutdownNow() on ExecutorService to avoid resource leaks.
- FixedThreadPool → best for CPU-bound or predictable workloads.
- CachedThreadPool → good for many short-lived async tasks but avoid unbounded growth.
- SingleThreadExecutor → ensures task order and sequential execution.
- ScheduledThreadPool → preferred over Timer/TimerTask for recurring tasks.
KEYWORDS:
executors executorservice future threadpool concurrency scheduledthreadpool java-docs.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 93090f8 commit e988673
File tree
1 file changed
+1
-1
lines changed- Section19MultiThreading/ThreadPooling/ExecutorsFramework/src/TXTFiles
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
0 commit comments