Thread pool provided by Java by default

Java thread pools are built through ThreadPoolExecutor.

In the executors factory class, Java provides four types of thread pools by default.

FixedThreadPool

Features of this thread pool:

CachedThreadPool

SingleThreadExecutor

Features of this thread pool:

ScheduledThreadPool

Scheduledthreadpoolexecutor inherits from ThreadPoolExecutor.

Features of this thread pool:

It receives tasks of type scheduledfuturetask. There are two ways to submit tasks:

It can be seen from the submission mode that this thread pool mainly deals with timed tasks or delayed tasks.

Parameters received by scheduledfuturetask:

It uses delayqueue to store waiting tasks:

Execution process of worker thread:

#########

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>