ThreadPoolExcutor

线程池将任务的提交与任务的执行解耦开来,它对线程进行管理和调度,通过合理的设置能够避免创建过多的线程,提高资源利用率和系统吞吐量。

ThreadPoolExecutor源码

Java中线程池为ThreadPoolExecutor,通过不同的参数设置来实现不同的线程池机制。首先ThreadPoolExcutor继承自AbstractExecutorService,而AbstractExecutorService实现了ExecutorService接口,它最核心构造函数如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) {
if (corePoolSize < 0 ||
maximumPoolSize <= 0 ||
maximumPoolSize < corePoolSize ||
keepAliveTime < 0)
throw new IllegalArgumentException();
if (workQueue == null || threadFactory == null || handler == null)
throw new NullPointerException();
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
this.workQueue = workQueue;
this.keepAliveTime = unit.toNanos(keepAliveTime);
this.threadFactory = threadFactory;
this.handler = handler;
}
参数名 作用
corePoolSize 核心线程池大小
maximumPoolSize 最大线程池大小
keepAliveTime 线程池中超过corePoolSize数目的空闲线程最大存活时间;可以allowCoreThreadTimeOut(true)使得核心线程有效时间
TimeUnit keepAliveTime时间单位
workQueue 阻塞任务队列
threadFactory 新建线程工厂
RejectedExecutionHandler 当提交任务数超过maxmumPoolSize+workQueue之和时,任务会交给RejectedExecutionHandler来处理

先看一下线程池的基本信息:

1
2
3
4
5
6
// 用一个线程安全的整数类型来保存线程池状态,并且前3位代表线程池状态,后面低位表示线程的数目
// 线程池的状态有:RUNNING,SHUTDOWN,STOP,TIDYING,TERMINATED
private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));
// 其中worker类对Runnable进行了封装,并且实现了AQS,其中lock方法主要用来判断线程池中的线程的状态(空闲、运行),以便线程池shutdown时进行中断判断
private final class Worker extends AbstractQueuedSynchronizer implements Runnable

Execute方法

首先分析一下其核心方法execute:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public void execute(Runnable command) {
if (command == null)
throw new NullPointerException();
int c = ctl.get();
// 小于核心线程数,则增加一个线程
if (workerCountOf(c) < corePoolSize) {
if (addWorker(command, true))
return;
c = ctl.get();
}
// 线程池Running状态,达到核心大小则加入阻塞队列
if (isRunning(c) && workQueue.offer(command)) {
int recheck = ctl.get();
// double check,防止加入队列过程中突然shutdown,则删除该任务,成功后拒绝
if (! isRunning(recheck) && remove(command))
reject(command);
// 若Running状态,或者shutdown但是队列还有任务,则必须增加新的线程处理,任务是null是由于shutdown状态下不能接受新的任务
else if (workerCountOf(recheck) == 0)
addWorker(null, false);
}
// 非Running状态,或队列满了,增加线程来处理,若达到最大线程大小,拒绝
else if (!addWorker(command, false))
reject(command);
}

由以上代码可知,线程处理、管理流程如下图:
img
下面简单总结下线程池在提交一个任务时的处理方法:
1.当线程池小于corePoolSize时,新提交任务将创建一个新线程执行任务,即使此时线程池中存在空闲线程。
2.当线程池达到corePoolSize时,新提交任务将被放入workQueue中,等待线程池中任务调度执行
3.当workQueue已满,且maximumPoolSize>corePoolSize时,新提交任务会创建新线程执行任务
4.当提交任务数超过maximumPoolSize时,新提交任务由RejectedExecutionHandler处理
5.当线程池中超过corePoolSize线程,空闲时间达到keepAliveTime时,关闭空闲线程
6.当设置allowCoreThreadTimeOut(true)时,线程池中corePoolSize线程空闲时间达到keepAliveTime也将关闭

AddWorker方法

下面继续分析一下addWorker方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// core表示是否为核心线程池
private boolean addWorker(Runnable firstTask, boolean core) {
retry:
for (;;) {
int c = ctl.get();
int rs = runStateOf(c);
// 线程池状态为shutdown以上, 或者为shutdown但是任务不为空(shutdown下不能接受新任务) 或队列为空 此时返回null,添加失败
if (rs >= SHUTDOWN &&
! (rs == SHUTDOWN &&
firstTask == null &&
! workQueue.isEmpty()))
return false;
for (;;) {
int wc = workerCountOf(c);
if (wc >= CAPACITY ||
wc >= (core ? corePoolSize : maximumPoolSize))
return false;
// 添加新的线程
if (compareAndIncrementWorkerCount(c))
break retry;
c = ctl.get(); // Re-read ctl
if (runStateOf(c) != rs)
continue retry;
// else CAS failed due to workerCount change; retry inner loop
}
}
boolean workerStarted = false;
boolean workerAdded = false;
Worker w = null;
try {
w = new Worker(firstTask);
final Thread t = w.thread;
if (t != null) {
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
// Recheck while holding lock.
// Back out on ThreadFactory failure or if
// shut down before lock acquired.
int rs = runStateOf(ctl.get());
// running状态 或者 shutdown状态任务为空,添加新的线程
if (rs < SHUTDOWN ||
(rs == SHUTDOWN && firstTask == null)) {
if (t.isAlive()) // precheck that t is startable
throw new IllegalThreadStateException();
workers.add(w);
int s = workers.size();
if (s > largestPoolSize)
largestPoolSize = s;
workerAdded = true;
}
} finally {
mainLock.unlock();
}
if (workerAdded) {
// 新线程执行,最终调用runWorker方法
t.start();
workerStarted = true;
}
}
} finally {
if (! workerStarted)
addWorkerFailed(w);
}
return workerStarted;
}

RunWorker方法

下面继续看看worker如何执行任务:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
final void runWorker(Worker w) {
Thread wt = Thread.currentThread();
Runnable task = w.firstTask;
w.firstTask = null;
w.unlock(); // allow interrupts
boolean completedAbruptly = true;
try {
// 不断从阻塞队列获取新的任务
while (task != null || (task = getTask()) != null) {
w.lock();
// If pool is stopping, ensure thread is interrupted;
// if not, ensure thread is not interrupted. This
// requires a recheck in second case to deal with
// shutdownNow race while clearing interrupt
// stop后需要中断线程
if ((runStateAtLeast(ctl.get(), STOP) ||
(Thread.interrupted() &&
runStateAtLeast(ctl.get(), STOP))) &&
!wt.isInterrupted())
wt.interrupt();
try {
beforeExecute(wt, task);
Throwable thrown = null;
try {
//直接执行任务的run方法
task.run();
} catch (RuntimeException x) {
thrown = x; throw x;
} catch (Error x) {
thrown = x; throw x;
} catch (Throwable x) {
thrown = x; throw new Error(x);
} finally {
afterExecute(task, thrown);
}
} finally {
task = null;
w.completedTasks++;
w.unlock();
}
}
completedAbruptly = false;
} finally {
processWorkerExit(w, completedAbruptly);
}
}

GetTask方法

线程池的线程如何不断获取任务:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
private Runnable getTask() {
boolean timedOut = false; // Did the last poll() time out?
for (;;) {
int c = ctl.get();
int rs = runStateOf(c);
// Check if queue empty only if necessary.
// 线程池状态为STOP以上或者shutdown并且队列为空,此时直接结束当前线程,线程数减1
if (rs >= SHUTDOWN && (rs >= STOP || workQueue.isEmpty())) {
decrementWorkerCount();
return null;
}
int wc = workerCountOf(c);
// Are workers subject to culling?
// 获取任务是否允许超时
boolean timed = allowCoreThreadTimeOut || wc > corePoolSize;
// 当获取任务超时并且还有其他线程或队列为空,终止当前线程
if ((wc > maximumPoolSize || (timed && timedOut))
&& (wc > 1 || workQueue.isEmpty())) {
if (compareAndDecrementWorkerCount(c))
return null;
continue;
}
try {
// 允许超时时间poll 否则直接阻塞take直到有新任务到
Runnable r = timed ?
workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS) :
workQueue.take();
if (r != null)
return r;
timedOut = true;
} catch (InterruptedException retry) {
timedOut = false;
}
}
}

当runWorker执行异常时:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
private void processWorkerExit(Worker w, boolean completedAbruptly) {
if (completedAbruptly) // If abrupt, then workerCount wasn't adjusted
decrementWorkerCount();
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
// 统计完成的任务,清除异常线程
completedTaskCount += w.completedTasks;
workers.remove(w);
} finally {
mainLock.unlock();
}
tryTerminate();
int c = ctl.get();
if (runStateLessThan(c, STOP)) {
if (!completedAbruptly) {
int min = allowCoreThreadTimeOut ? 0 : corePoolSize;
if (min == 0 && ! workQueue.isEmpty())
min = 1;
// 线程池不为空,直接返回
if (workerCountOf(c) >= min)
return; // replacement not needed
}
// 线程池异常,防止队列有任务而没有worker,需要增加一个新的线程处理任务
addWorker(null, false);
}
}

TryTerminate方法

当线程池异常或shutdown或减少线程池线程数量时,会调用tryTerminate方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
final void tryTerminate() {
for (;;) {
int c = ctl.get();
// Running状态,TIDTYING,shutdown但是队列非空直接返回
if (isRunning(c) ||
runStateAtLeast(c, TIDYING) ||
(runStateOf(c) == SHUTDOWN && ! workQueue.isEmpty()))
return;
// shotdown状态并且队列非空,清除空闲线程
if (workerCountOf(c) != 0) { // Eligible to terminate
interruptIdleWorkers(ONLY_ONE);
return;
}
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
// CAS设置状态为TIDYING
if (ctl.compareAndSet(c, ctlOf(TIDYING, 0))) {
try {
terminated();
} finally {
ctl.set(ctlOf(TERMINATED, 0));
termination.signalAll();
}
return;
}
} finally {
mainLock.unlock();
}
// else retry on failed CAS
}
}
private void interruptIdleWorkers(boolean onlyOne) {
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
for (Worker w : workers) {
Thread t = w.thread;
// 通过aqs的lock方法判断是否空闲,在runWoker()方法可以看到
if (!t.isInterrupted() && w.tryLock()) {
try {
t.interrupt();
} catch (SecurityException ignore) {
} finally {
w.unlock();
}
}
if (onlyOne)
break;
}
} finally {
mainLock.unlock();
}
}

Shutdown方法

最后看下shutdown方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public void shutdown() {
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
checkShutdownAccess();
// 设置shutdown状态并中断空闲线程
advanceRunState(SHUTDOWN);
interruptIdleWorkers();
onShutdown(); // hook for ScheduledThreadPoolExecutor
} finally {
mainLock.unlock();
}
// 剩下的任务继续执行
tryTerminate();
}
public List<Runnable> shutdownNow() {
List<Runnable> tasks;
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
checkShutdownAccess();
// 设置stop状态
advanceRunState(STOP);
//终止所有线程
interruptWorkers();
tasks = drainQueue();
} finally {
mainLock.unlock();
}
tryTerminate();
return tasks;
}
private void interruptWorkers() {
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
try {
for (Worker w : workers)
w.interruptIfStarted();
} finally {
mainLock.unlock();
}
}

WorkQueue的类型

直接提交

SynchronousQueue它将任务直接提交给线程而不保持它们。在此,如果不存在可用于立即运行任务的线程,则试图把任务加入队列将失败,因此会构造一个新的线程。此策略可以避免在处理可能具有内部依赖性的请求集时出现锁。直接提交通常要求无界 maximumPoolSizes或者可以拒绝的。当命令以超过队列所能处理的平均数连续到达时,此策略允许无界线程具有增长的可能性。

无界队列

使用无界队列(例如,不具有预定义容量的 LinkedBlockingQueue)将导致在所有 corePoolSize 线程都忙时新任务在队列中等待。这样,创建的线程就不会超过 corePoolSize。(因此,maximumPoolSize 的值也就无效了。)当每个任务完全独立于其他任务,即任务执行互不影响时,适合于使用无界队列;例如,在 Web 页服务器中。这种排队可用于处理瞬态突发请求,当命令以超过队列所能处理的平均数连续到达时,此策略允许无界线程具有增长的可能性。

有界队列

当使用有限的 maximumPoolSizes 时,有界队列(如 ArrayBlockingQueue、LinkedBlockingQueue、PriorityBlockingQueue)有助于防止资源耗尽,但是可能较难调整和控制。队列大小和最大池大小可能需要相互折衷:使用大型队列和小型池可以最大限度地降低 CPU 使用率、操作系统资源和上下文切换开销,但是可能导致人工降低吞吐量。如果任务频繁阻塞(例如,如果它们是 I/O 边界),则系统可能为超过您许可的更多线程安排时间。使用小型队列通常要求较大的池大小,CPU 使用率较高,但是可能遇到不可接受的调度开销,这样也会降低吞吐量。

ThreadFactory

每当线程池需要创建一个线程时,都会通过threadFactory的工厂方法newThreadFactory来创建一个新的、非守护线程,当然可以继承ThreadFactory来自定义创建的线程,设置线程的优先级、名字、增加日志等功能。

RejectedExecutionHandler

当当提交任务数超过maximumPoolSize、队列已满时将采取拒绝策略,这将调用RejectedExecutionHandler的rejectedExecution方法,ThreadPoolExcutor 提供了4种预定义的拒绝策略:
1.在默认的 ThreadPoolExecutor.AbortPolicy 中,处理程序遭到拒绝将抛出运行时 RejectedExecutionException
2.在 ThreadPoolExecutor.CallerRunsPolicy 中,线程调用运行该任务的 execute 本身即在excute本身的线程中执行run方法。此策略提供简单的反馈控制机制,能够减缓新任务的提交速度。
3.在 ThreadPoolExecutor.DiscardPolicy 中,当前的任务将被抛弃。
4.在 ThreadPoolExecutor.DiscardOldestPolicy 中,如果执行程序尚未关闭,则位于工作队列头部(注意优先级队列)的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)

Executors常用的线程池配置

newFixedThreadPool

构造一个固定线程数目的线程池,配置的corePoolSize与maximumPoolSize大小相同,同时使用了一个无界LinkedBlockingQueue存放阻塞任务,因此多余的任务将存在再阻塞队列,不会由RejectedExecutionHandler处理

1
2
3
4
5
public static ExecutorService newFixedThreadPool(int nThreads) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
}

newCachedThreadPool

构造一个缓冲功能的线程池,配置corePoolSize=0,maximumPoolSize=Integer.MAX_VALUE,keepAliveTime=60s,以及一个无容量的阻塞队列 SynchronousQueue,因此任务提交之后,将会创建新的线程执行;线程空闲超过60s将会销毁

1
2
3
4
5
public static ExecutorService newCachedThreadPool() {
return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
}

newSingleThreadExecutor

构造一个只支持一个线程的线程池,配置corePoolSize=maximumPoolSize=1,无界阻塞队列LinkedBlockingQueue;保证任务由一个线程串行执行

1
2
3
4
5
6
public static ExecutorService newSingleThreadExecutor() {
return new FinalizableDelegatedExecutorService
(new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>()));
}

newScheduledThreadPool

构造有定时功能的线程池,配置corePoolSize,无界延迟阻塞队列DelayedWorkQueue;有意思的是:maximumPoolSize=Integer.MAX_VALUE,由于DelayedWorkQueue是无界队列,所以这个值是没有意义的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) {
return new ScheduledThreadPoolExecutor(corePoolSize);
}
public static ScheduledExecutorService newScheduledThreadPool(
int corePoolSize, ThreadFactory threadFactory) {
return new ScheduledThreadPoolExecutor(corePoolSize, threadFactory);
}
public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory) {
super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
new DelayedWorkQueue(), threadFactory);
}

自定义线程池

下面我们自定义写一个线程池:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.meituan.concurrent;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
/**
* Author:fuyang@meituan.com
* Date:16/7/20
* Time:下午2:13
*/
public class ThreadPoolExecuotrTest extends ThreadPoolExecutor {
private final ThreadLocal<Long> startTime = new ThreadLocal<Long>();
private final AtomicLong executeTime = new AtomicLong(0);
public ThreadPoolExecuotrTest(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, new MyThreadFactory(), new RejectHandler());
}
@Override
protected void beforeExecute(Thread t, Runnable r) {
super.beforeExecute(t, r);
System.out.println(Thread.currentThread().getName()+" before");
startTime.set(System.currentTimeMillis());
}
@Override
protected void afterExecute(Runnable r, Throwable t) {
long endTime = System.currentTimeMillis();
executeTime.addAndGet(endTime - startTime.get());
System.out.println(Thread.currentThread().getName()+" after");
super.afterExecute(r, t);
}
@Override
protected void terminated() {
System.out.println("time " + executeTime.get());
super.terminated();
}
public static void main(String[] args) {
ThreadPoolExecuotrTest threadPoolExecuotrTest = new ThreadPoolExecuotrTest(2, 4, 10, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(2));
for (int i = 0; i < 8; i++) {
threadPoolExecuotrTest.execute(new Runnable() {
public void run() {
try {
System.out.println(Thread.currentThread().getName() + " execute");
Thread.sleep(6000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
threadPoolExecuotrTest.shutdown();
}
}

执行8次任务,那么线程池中达到最大线程数,队列也会打满,那么剩下的2个任务将会采取拒绝策略,我们复写了rejectExecution方法,将任务put阻塞提交到队列,所以所有的任务的都会执行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.meituan.concurrent;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* Author:fuyang@meituan.com
* Date:16/7/20
* Time:下午3:23
*/
public class RejectHandler implements RejectedExecutionHandler {
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
System.out.println("reject");
try {
executor.getQueue().put(r);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

执行结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Connected to the target VM, address: '127.0.0.1:54007', transport: 'socket'
com.meituan.concurrent.MyThreadFactory-1 before
com.meituan.concurrent.MyThreadFactory-4 before
com.meituan.concurrent.MyThreadFactory-1 execute
reject
com.meituan.concurrent.MyThreadFactory-3 before
com.meituan.concurrent.MyThreadFactory-3 execute
com.meituan.concurrent.MyThreadFactory-2 before
com.meituan.concurrent.MyThreadFactory-4 execute
com.meituan.concurrent.MyThreadFactory-2 execute
com.meituan.concurrent.MyThreadFactory-4 after
com.meituan.concurrent.MyThreadFactory-2 after
com.meituan.concurrent.MyThreadFactory-1 after
com.meituan.concurrent.MyThreadFactory-3 after
com.meituan.concurrent.MyThreadFactory-2 before
com.meituan.concurrent.MyThreadFactory-2 execute
reject
com.meituan.concurrent.MyThreadFactory-4 before
com.meituan.concurrent.MyThreadFactory-4 execute
com.meituan.concurrent.MyThreadFactory-3 before
com.meituan.concurrent.MyThreadFactory-3 execute
com.meituan.concurrent.MyThreadFactory-1 before
com.meituan.concurrent.MyThreadFactory-1 execute
Disconnected from the target VM, address: '127.0.0.1:54007', transport: 'socket'
com.meituan.concurrent.MyThreadFactory-4 after
com.meituan.concurrent.MyThreadFactory-3 after
com.meituan.concurrent.MyThreadFactory-2 after
com.meituan.concurrent.MyThreadFactory-1 after
time 48016

另外,线程池中shutdown方法通过interrupt中断线程,设置为shutdown状态,但只能中断空闲线程,阻止继续提交任务,队列中的任务仍会执行,shutdownNow会interrupt所有的线程,设置为stop 状态,但不能保证所有的线程马上结束(参考interrupt作用),队列中的任务也会丢弃不执行。awaitTermination阻塞等待shutdown后线程结束。

Tips

一般来说,最好使用Executors提供的4种线程池,除非有特别的需求可以定义独特的线程池,线程池的大小确定是重点,线程池过大导致竞争激烈,线程池过小吞吐量较低。所以在任务量较少可以使用无界的队列,任务量很大使用有介的队列防止OOM,也有一种通用的计算方法:N(thread)=N(cpu)*U(cpu)(1+W / C),其中分别为cpu数量,cpu利用率,等待时间和计算时间,最大线程数一般设为2N+1,N是CPU核数。当然线程池大小还受到内存,io等其他因素影响。

最后注意线程间的依赖,在有界线程池中容易产生死锁现象。
线程池这部分知识感觉有些复杂,掌握起来有些困难,底层一些机制源码不太容易理解。

谢谢大佬的打赏!