Commit 93090f8
committed
docs(concurrency): add detailed theory on Executors Framework in Java
WHAT was added:
- Comprehensive explanation of the Executors Framework (introduced in Java 5, part of java.util.concurrent).
- Reasons for using Executors:
• Efficient thread management (reuse threads, reduce overhead).
• Optimized performance (prevent thread explosion).
• Better control (limit active threads, execution policies).
• Simplified multi-threading (removes manual Thread handling).
- Core components explained:
• Executor → base interface with execute(Runnable).
• ExecutorService → extends Executor with lifecycle & result retrieval.
• Executors → utility class with factory methods for thread pools.
• Future → handle asynchronous computation results.
- Table summarizing thread pool types:
• FixedThreadPool → bounded concurrency.
• CachedThreadPool → dynamic, unbounded scaling.
• SingleThreadExecutor → sequential execution guarantee.
• ScheduledThreadPool → delayed & periodic task execution.
- Advantages list: performance, resource management, scalability, flexibility.
WHY this matters:
- Provides foundational knowledge for Java concurrency.
- Explains WHY Executors are preferred over manual thread creation.
- Highlights which pool type to use in different scenarios (CPU-bound, I/O-bound, sequential, scheduled).
HINTS:
- Always call shutdown() on ExecutorService to release resources.
- FixedThreadPool → good for predictable, limited parallelism.
- CachedThreadPool → best for many short-lived async tasks.
- SingleThreadExecutor → ensures order and single-thread execution.
- ScheduledThreadPool → modern replacement for Timer/TimerTask.
KEYWORDS:
executors executorservice future threadpool scheduledthreadpool java concurrency theory.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 13e5635 commit 93090f8
File tree
1 file changed
+9
-14
lines changed- Section19MultiThreading/ThreadPooling/ExecutorsFramework/src/TXTFiles
1 file changed
+9
-14
lines changedLines changed: 9 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | | - | |
46 | 42 | | |
47 | 43 | | |
48 | 44 | | |
49 | | - | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| |||
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments