Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of Executor?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you what is the principle of Executor, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Introduction of Executor thread pool system. 1. Introduction of Executor framework

Executor: the uppermost parent interface of the java thread pool framework. In Executor, there is only the executor () method, which means that the thread pool of type Runnable is committed and executed.

ExecutorService: a subinterface of Executor, where the submit () method receives either Runnable or Callable parameters, and closes the thread pool using the shutdown () method after use, and no longer receives new tasks.

AbstractExecutorService: the default implementation class for ExecutorService.

ScheduledExecutorService: a subinterface of ExecutorService, which can be used for scheduled task scheduling.

ScheduledThreadPoolExecutor: provides another thread pool, thread pool for deferred and periodic execution.

ThreadPoolExecutor: the core class of AbstractExecutorService thread pool, which inherits from Java. The main function of Java thread pool is to create thread pool, assign thread resources to tasks, and execute tasks.

2. ThreadPoolExecutor source code parsing

ThreadPoolExecutor has several overloaded constructors, and we analyze the role of each parameter based on the most complete constructor.

Public ThreadPoolExecutor (int corePoolSize, / / number of core thread pools int maximumPoolSize, / / maximum number of thread pools long keepAliveTime, / / the number of threads is greater than the number of core thread pools The maximum survival time of idle threads TimeUnit unit, / / the time unit of the parameter BlockingQueue workQueue, / / thread waiting queue ThreadFactory threadFactory / / set the factory RejectedExecutionHandler handler for creating threads) {/ / set the deny policy if (corePoolSize < 0 | | maximumPoolSize)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report