Unified management of multi-threading----"thread pool

 

The problem of multi-threading has been dealt with before. Here we will talk about the unified management of multi-threading.

Manage creation, recycling (validity), cache queues

 

ThreadPoolExecutor类(java.util.concurrent.ThreadPoolExecutor)

 

It is the core implementation class of the thread pool, which is used to execute the submitted tasks.

 

It is usually created by the factory class Executors. Executors can create different ThreadPoolExecutors such as SingleThreadExecutor, FixedThreadPool and CachedThreadPool.

 

That is to say, threadpoolexecutor is a global thread pool. If a specific thread pool is set, the new setting can override the global default parameters.

 

 

 

The tasks performed by these thread pools can be runnables without return values ​​or callables with return values. When there is no packaging, the return results need to be converted into Futures before taking them.

FutureTask is specially packaged for callable, and the execution still needs to land on thread, threadpool, and this package takes the return value

 

 

There will be several multi-threaded containers introduced later

Multithreading Manager:

 

1, ThreadPoolExecutor introduction

 

2, Executor introduction

 

3. There is an introduction to the returned Future

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326254611&siteId=291194637