-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_7.html
More file actions
756 lines (548 loc) · 27.3 KB
/
Copy pathJava_7.html
File metadata and controls
756 lines (548 loc) · 27.3 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>
Java - 非著名Java程序员
</title>
<link href="atom.xml" rel="alternate" title="非著名Java程序员" type="application/atom+xml">
<link href="asset/css/foundation.min.css" rel="stylesheet"/>
<link href="asset/css/docs.css" rel="stylesheet"/>
<script src="asset/js/vendor/modernizr.js"></script>
<script src="asset/js/vendor/jquery.js"></script>
<script type="text/javascript">
function before_search() {
var searchVal = 'site:blog.hitol.top ' + document.getElementById('search_input').value;
document.getElementById('search_q').value = searchVal;
return true;
}
</script>
</head>
<body class="antialiased hide-extras">
<div class="marketing off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">
<nav class="top-bar docs-bar hide-for-small" data-topbar>
<section class="top-bar-section">
<div class="row">
<div style="position: relative;width:100%;">
<div style="position: absolute; width:100%;">
<ul class="left" id="main-menu">
<li id=""><a href="index.html" target="_self">Home</a></li>
<li id=""><a href="archives.html" target="_self">Archives</a></li>
<li id=""><a href="about1.html" target="_self">About</a></li>
</ul>
<ul class="right" id="search-wrap">
<li>
<form action="https://google.com/search" method="get"
onsubmit="return before_search();"
target="_blank">
<input id="search_q" name="q" type="hidden" value=""/>
<input id="search_input" placeholder="Search" tabindex="1" type="search"/>
</form>
</li>
</ul>
</div>
</div>
</div>
</section>
</nav>
<nav class="tab-bar show-for-small">
<a class="left-off-canvas-toggle menu-icon" href="javascript:void(0)">
<span> 非著名Java程序员</span>
</a>
</nav>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li><a href="index.html" target="_self">Home</a></li>
<li><a href="archives.html" target="_self">Archives</a></li>
<li><a href="about1.html" target="_self">About</a></li>
<li><label>Categories</label></li>
<li><a href="rust.html">rust</a></li>
<li><a href="redis.html">redis</a></li>
<li><a href="dubbo.html">dubbo</a></li>
<li><a href="RocketMQ.html">RocketMQ</a></li>
<li><a href="kubernetes.html">kubernetes</a></li>
<li><a href="Java%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B%E7%9A%84%E8%89%BA%E6%9C%AF.html">Java并发编程的艺术</a></li>
<li><a href="%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE.html">网络协议</a></li>
<li><a href="JVM.html">JVM</a></li>
<li><a href="Java.html">Java</a></li>
<li><a href="MySQL.html">MySQL</a></li>
<li><a href="Docker.html">Docker</a></li>
<li><a href="Spring.html">Spring</a></li>
<li><a href="GO.html">GO</a></li>
<li><a href="AI.html">AI</a></li>
</ul>
</aside>
<a class="exit-off-canvas" href="#"></a>
<section class="scroll-container" id="main-content" role="main"> <script type="text/javascript">
$(function () {
$('#menu_item_index').addClass('is_active');
});
</script>
<div class="row">
<div class="large-8 medium-8 columns">
<div class="markdown-body home-categories">
<div class="article">
<a class="clearlink" href="16032822063276.html">
<h1>线程池</h1>
<div class="a-content">
<div class="a-content-text">
<div class="mweb_toc"><ul>
<li><a href="#%E7%BA%BF%E7%A8%8B%E6%B1%A0%E6%98%AF%E4%BB%80%E4%B9%88">线程池是什么</a></li>
<li><a href="#%E7%BA%BF%E7%A8%8B%E6%B1%A0%E8%A7%A3%E5%86%B3%E7%9A%84%E9%97%AE%E9%A2%98">线程池解决的问题</a></li>
<li><a href="#%E7%BA%BF%E7%A8%8B%E6%B1%A0%E8%BF%90%E8%A1%8C%E6%9C%BA%E5%88%B6">线程池运行机制</a></li>
<li><a href="#%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E7%9A%84%E5%9B%9B%E7%A7%8D%E6%96%B9%E5%BC%8F">创建线程池的四种方式</a>
<ul>
<li><a href="#newcachedthreadpool">newCachedThreadPool</a></li>
<li><a href="#newfixedthreadpool">newFixedThreadPool</a></li>
<li><a href="#newscheduledthreadpool">newScheduledThreadPool</a></li>
<li><a href="#newsinglethreadexecutor">newSingleThreadExecutor</a></li>
</ul>
</li>
<li><a href="#%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%A4%A7%E5%B0%8F%E5%88%86%E9%85%8D">线程池大小分配</a></li>
</ul>
</div>
<h2><a id="%E7%BA%BF%E7%A8%8B%E6%B1%A0%E6%98%AF%E4%BB%80%E4%B9%88" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>线程池是什么</h2>
<p>线程池是一种基于池化思想来管理线程的工具。<br />
使用线程池的好处:</p>
<ul>
<li>降低资源消耗:通过池化技术复用已经创建的线程,降低线程创建和销毁造成的损耗。</li>
<li>提高响应速度:任务到达时,无需等待线程创建即可执行。</li>
<li>提高线程的可管理性:使用线程池进行统一的分配、调优和监控。</li>
<li>提供更多更强大的功能:比如延时定时线程池ScheduledThreadPoolExecutor,就允许任务延期执行或定期执行。</li>
</ul>
<h2><a id="%E7%BA%BF%E7%A8%8B%E6%B1%A0%E8%A7%A3%E5%86%B3%E7%9A%84%E9%97%AE%E9%A2%98" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>线程池解决的问题</h2>
<p>线程池解决的核心问题就是资源管理问题。<br />
1、频繁申请、销毁资源和调度资源,将带来额外的消耗,可能非常巨大。<br />
2、对资源无限申请,缺少抑制手段,易引发系统资源耗尽的风险。<br />
3、系统无法合理管理内部的资源分布,会降低系统的稳定性。</p>
<h2><a id="%E7%BA%BF%E7%A8%8B%E6%B1%A0%E8%BF%90%E8%A1%8C%E6%9C%BA%E5%88%B6" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>线程池运行机制</h2>
<p><img src="http://hitol.blog.cdn.updev.cn/16023122966589.jpg" alt="16023122966589" /></p>
<details>
<summary>ThreadPoolExecutor构造方法</summary>
```
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.acc = System.getSecurityManager() == null ?
null :
AccessController.getContext();
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
this.workQueue = workQueue;
this.keepAliveTime = unit.toNanos(keepAliveTime);
this.threadFactory = threadFactory;
this.handler = handler;
}
```
</details>
<p>这几个核心参数的作用:</p>
<ul>
<li>corePoolSize:核心线程数,为线程池的基本大小。<strong>核心线程不会被回收</strong>,即使没有任务执行,也会保持空闲状态。</li>
<li>maximumPoolSize:为线程池最大线程大小。<strong>当线程运行数量达到corePoolSize,且workQueue队列塞满任务了之后</strong>,继续创建线程。</li>
<li>keepAliveTime 和 unit :是超过corePoolSize之后的“临时线程”的存活时间。</li>
<li>workQueue:用于存放任务的阻塞队列。当前运行线程超过核心线程数时,新的任务会处于等待状态,存在workQueue中,BlockingQueue是一个阻塞式队列,相当于一个容器,生产者往里面放资源,消费者从里面拿资源。</li>
<li>handler:当队列和最大线程池都满了之后的饱和策略。</li>
</ul>
<p>阻塞队列:<br />
<img src="http://hitol.blog.cdn.updev.cn/16023150102703.jpg" alt="16023150102703" /></p>
<p>首先检测线程池运行状态,如果不是RUNNING,则直接拒绝,线程池要保证在RUNNING的状态下执行任务。</p>
<ul>
<li>如果workerCount < corePoolSize,则创建并启动一个线程来执行新提交的任务。</li>
<li>如果workerCount >= corePoolSize,且线程池内的阻塞队列未满,则将任务添加到该阻塞队列中。</li>
<li>如果workerCount >= corePoolSize && workerCount < maximumPoolSize,且线程池内的阻塞队列已满,则创建并启动一个线程来执行新提交的任务。</li>
<li>如果workerCount >= maximumPoolSize,并且线程池内的阻塞队列已满, 则根据拒绝策略来处理该任务, 默认的处理方式是直接抛异常。<br />
其执行流程如下图所示:</li>
</ul>
<p><img src="http://hitol.blog.cdn.updev.cn/16023179404989.jpg" alt="16023179404989" /></p>
<p>线程运行状态:<br />
<img src="http://hitol.blog.cdn.updev.cn/16023123528952.jpg" alt="16023123528952" /></p>
<p>拒绝策略<br />
<img src="http://hitol.blog.cdn.updev.cn/16023245427842.jpg" alt="16023245427842" /></p>
<h2><a id="%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E7%9A%84%E5%9B%9B%E7%A7%8D%E6%96%B9%E5%BC%8F" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>创建线程池的四种方式</h2>
<h3><a id="newcachedthreadpool" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>newCachedThreadPool</h3>
<pre class="line-numbers"><code class="language-plain_text">public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) {
return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(),
threadFactory);
}
</code></pre>
<p>通过源码可以返现,这种方式创建的线程池,其核心线程数为0,最大线程数为 Integer 的最大值,线程存活时间 60s,还有这个 SynchronousQueue,这个队列没有存储空间,有任务提交后就必须去执行。</p>
<p>当有任务提交后,会去看有没有还存活的空闲线程,有的话让线程去执行任务,没有存活线程的话会立即创建线程执行该任务</p>
<p>弊端:<br />
并发量大了后线程创建的太多,导致 OOM</p>
<h3><a id="newfixedthreadpool" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>newFixedThreadPool</h3>
<pre class="line-numbers"><code class="language-plain_text">public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
threadFactory);
}
</code></pre>
<p>核心线程数与最大线程数一样,空闲线程存活时间为0,有序队列。</p>
<p>当有任务提交时,该线程池始终以核心线程去执行,核心线程满了后进入队列等待,FIFO</p>
<p>弊端:<br />
因为队列容量无限大,可能会出现请求太多,出现 OOM</p>
<h3><a id="newscheduledthreadpool" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>newScheduledThreadPool</h3>
<p>可以延迟处理,或者定时处理</p>
<pre class="line-numbers"><code class="language-plain_text">public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory) {
super(corePoolSize, Integer.MAX_VALUE, 0, NANOSECONDS,
new DelayedWorkQueue(), threadFactory);
}
</code></pre>
<p>核心线程数可以指定,最大线程数是 Integer 最大值,空闲线程存存活时间为0,</p>
<h3><a id="newsinglethreadexecutor" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>newSingleThreadExecutor</h3>
<pre class="line-numbers"><code class="language-plain_text">public static ExecutorService newSingleThreadExecutor() {
return new FinalizableDelegatedExecutorService
(new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>()));
}
</code></pre>
<p>最大线程数与核心线程数都是1,队列有序无限大,</p>
<p>可能导致OOM</p>
<h2><a id="%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%A4%A7%E5%B0%8F%E5%88%86%E9%85%8D" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>线程池大小分配</h2>
<ul>
<li>
<p>IO 密集型<br />
指的是 CPU 运算能力较好<br />
CPU 核心数 * 2</p>
</li>
<li>
<p>CPU 密集型<br />
指的是,CPU 运算能力较差<br />
CPU 个数 +1</p>
</li>
<li>
<p>混合型</p>
</li>
<li>
<p>任务类型不同</p>
</li>
</ul>
<p>--<br />
现有一个线程池,参数corePoolSize = 5,maximumPoolSize = 10,BlockingQueue阻塞队列长度为5,此时有4个任务同时进来,问:线程池会创建几条线程?</p>
<p>如果4个任务还没处理完,这时又同时进来2个任务,问:线程池又会创建几条线程还是不会创建?</p>
<p>如果前面6个任务还是没有处理完,这时又同时进来5个任务,问:线程池又会创建几条线程还是不会创建?</p>
<p>--<br />
<a href="https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html">https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html</a><br />
<a href="http://objcoding.com/2019/04/11/threadpool-initial-parameters/">http://objcoding.com/2019/04/11/threadpool-initial-parameters/</a><br />
<a href="https://www.cnblogs.com/frankyou/p/10135212.html">https://www.cnblogs.com/frankyou/p/10135212.html</a><br />
<a href="https://www.cnblogs.com/NiceCui/p/11929396.html">https://www.cnblogs.com/NiceCui/p/11929396.html</a></p>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<span class="date">2020/10/21 20:10 下午</span>
<span>posted in </span>
<span class="posted-in"><a href='Java.html'>Java</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="row">
<div class="large-6 columns">
<p class="text-left" style="padding-top:25px;">
<a href="Java_6.html">« Prev Page</a>
</p>
</div>
<div class="large-6 columns">
<p class="text-right" style="padding-top:25px;">
<a href="Java_8.html">» Next Page</a>
</p>
</div>
</div>
</div>
</div><!-- large 8 -->
<div class="large-4 medium-4 columns">
<div class="hide-for-small">
<div class="sidebar" id="sidebar">
<div class="site-info" id="site-info">
<div class="site-a-logo"><img src="https://avatars.githubusercontent.com/u/20561936?s=400&u=b0f8f4e37a7fb9306d116b0c5ae7e3da0737a6c1&v=4"/></div>
<h1>非著名Java程序员</h1>
<div class="site-des">Java Developer 准备转行 Rust</div>
<div class="social">
<a class="github" href="https://github.com/hitolz" target="_blank"
target="_blank" title="GitHub">GitHub</a>
<a class="rss" href="atom.xml" target="_blank" title="RSS">RSS</a>
</div>
</div>
<div class="side-item " id="site-categories">
<div class="side-header">
<h2>公众号</h2>
</div>
<div class="side-content">
<div class="bg-info site_notice" style="color:#ff0000; text-align:center; padding:8px;">
<p><img src="http://hitol.blog.cdn.updev.cn/mweb/qrcode_for_gh_47004627b29e_258.jpg"></p>
</div>
</div>
</div>
<div class="side-item " id="site-categories">
<div class="side-header">
<h2>Categories</h2>
</div>
<div class="side-content">
<p class="cat-list">
<a href="rust.html"><strong>rust</strong></a>
<a href="redis.html"><strong>redis</strong></a>
<a href="dubbo.html"><strong>dubbo</strong></a>
<a href="RocketMQ.html"><strong>RocketMQ</strong></a>
<a href="kubernetes.html"><strong>kubernetes</strong></a>
<a href="Java%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B%E7%9A%84%E8%89%BA%E6%9C%AF.html"><strong>Java并发编程的艺术</strong></a>
<a href="%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE.html"><strong>网络协议</strong></a>
<a href="JVM.html"><strong>JVM</strong></a>
<a href="Java.html"><strong>Java</strong></a>
<a href="MySQL.html"><strong>MySQL</strong></a>
<a href="Docker.html"><strong>Docker</strong></a>
<a href="Spring.html"><strong>Spring</strong></a>
<a href="GO.html"><strong>GO</strong></a>
<a href="AI.html"><strong>AI</strong></a>
</p>
</div>
</div>
<div class="side-item" id="site-categories">
<div class="side-header">
<h2>Recent Posts</h2>
</div>
<div class="side-content">
<ul class="posts-list">
<li class="post">
<a href="16748079623338.html">rust 快速入门指南</a>
</li>
<li class="post">
<a href="17805648014078.html">写给儿童节见过的女孩</a>
</li>
<li class="post">
<a href="17767631984690.html">AI Agent 开发</a>
</li>
<li class="post">
<a href="17506516792982.html">RFC 3339</a>
</li>
<li class="post">
<a href="17048514855506.html">记一次公众号菜单配置</a>
</li>
</ul>
</div>
</div>
</div><!-- sidebar -->
</div><!-- hide for small -->
</div><!-- large 4 -->
</div><!-- row -->
<div class="page-bottom clearfix">
<div class="row">
<p class="copyright">Copyright © 2015
Powered by <a href="http://www.mweb.im" target="_blank">MWeb</a>,
Theme used <a href="http://github.com" target="_blank">GitHub CSS</a>.</p>
</div>
</div>
</section>
</div>
</div>
<style type="text/css">
figure {
margin: 0;
padding: 0;
}
figcaption {
text-align: center;
}
/* PrismJS 1.14.0
http://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #F7F7F7;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function,
.token.class-name {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
pre[class*="language-"].line-numbers {
position: relative;
padding-left: 3.8em;
counter-reset: linenumber;
}
pre[class*="language-"].line-numbers > code {
position: relative;
white-space: inherit;
}
.line-numbers .line-numbers-rows {
position: absolute;
pointer-events: none;
top: 0;
font-size: 100%;
left: -3.8em;
width: 3em; /* works for line-numbers below 1000 lines */
letter-spacing: -1px;
border-right: 1px solid #999;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.line-numbers-rows > span {
pointer-events: none;
display: block;
counter-increment: linenumber;
}
.line-numbers-rows > span:before {
content: counter(linenumber);
color: #999;
display: block;
padding-right: 0.8em;
text-align: right;
}
</style>
<script src="asset/js/foundation.min.js"></script>
<script>
$(document).foundation();
function fixSidebarHeight() {
var w1 = $('.markdown-body').height();
var w2 = $('#sidebar').height();
if (w1 > w2) {
$('#sidebar').height(w1);
}
;
}
$(function () {
fixSidebarHeight();
})
$(window).load(function () {
fixSidebarHeight();
});
</script>
<!-- <link rel="stylesheet" href="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.11/tianli_gpt.css">
<script>
let tianliGPT_postSelector = '.article-content';
let tianliGPT_key = '5Q5mpqRK5DkwT1X9Gi5e';
</script>
<script src="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.11/tianli_gpt.js"></script> -->
</body>
</html>