File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 13
13
14
14
` Executors ` 返回线程池对象的弊端如下(后文会详细介绍到):
15
15
16
- - ** ` FixedThreadPool ` 和 ` SingleThreadExecutor ` ** :使用的是无界的 ` LinkedBlockingQueue ` ,任务队列最大长度为 ` Integer.MAX_VALUE ` , 可能堆积大量的请求,从而导致 OOM。
17
- - ** ` CachedThreadPool ` ** :使用的是同步队列 ` SynchronousQueue ` , 允许创建的线程数量为 ` Integer.MAX_VALUE ` ,可能会创建大量线程,从而导致 OOM。
18
- - ** ` ScheduledThreadPool ` 和 ` SingleThreadScheduledExecutor ` ** : 使用的无界的延迟阻塞队列` DelayedWorkQueue ` ,任务队列最大长度为 ` Integer.MAX_VALUE ` , 可能堆积大量的请求,从而导致 OOM。
16
+ - ** ` FixedThreadPool ` 和 ` SingleThreadExecutor ` ** :使用的是有界阻塞队列 ` LinkedBlockingQueue ` ,任务队列的默认长度和最大长度为 ` Integer.MAX_VALUE ` , 可能堆积大量的请求,从而导致 OOM。
17
+ - ** ` CachedThreadPool ` ** :使用的是同步队列 ` SynchronousQueue ` , 允许创建的线程数量为 ` Integer.MAX_VALUE ` ,可能会创建大量线程,从而导致 OOM。
18
+ - ** ` ScheduledThreadPool ` 和 ` SingleThreadScheduledExecutor ` ** : 使用的无界的延迟阻塞队列` DelayedWorkQueue ` ,任务队列最大长度为 ` Integer.MAX_VALUE ` , 可能堆积大量的请求,从而导致 OOM。
19
19
20
20
说白了就是:** 使用有界队列,控制线程创建数量。**
21
21
You can’t perform that action at this time.
0 commit comments