-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_1.html
More file actions
966 lines (731 loc) · 32.5 KB
/
Copy pathJava_1.html
File metadata and controls
966 lines (731 loc) · 32.5 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
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
<!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="16272819939818.html">
<h1>AQS</h1>
<div class="a-content">
<div class="a-content-text">
<div class="mweb_toc"><ul>
<li><a href="#reentrantlock">ReentrantLock</a>
<ul>
<li><a href="#%E5%8A%A0%E9%94%81%E8%BF%87%E7%A8%8B">加锁过程</a></li>
<li><a href="#reentrantlock-unlock%E8%A7%A3%E9%94%81%E8%BF%87%E7%A8%8B">ReentrantLock unlock 解锁过程</a></li>
<li><a href="#%E9%9D%9E%E5%85%AC%E5%B9%B3%E9%94%81">非公平锁</a></li>
</ul>
</li>
<li><a href="#locksupport">LockSupport</a></li>
</ul>
</div>
<p>Java 并发编程核心在于 juc 包,而其中大多数同步器实现都是围绕着共同的基础行为,比如等待队列、条件队列、独占获取、共享获取等,而这个行为的抽象就是 AQS。</p>
<p>AQS 定义了一套多线程访问共享资源的同步器框架,是一个依赖状态(volatile int state)的同步器。</p>
<blockquote>
<p>Provides a framework for implementing blocking locks and related synchronizers (semaphores, events, etc) that rely on first-in-first-out (FIFO) wait queues. This class is designed to be a useful basis for most kinds of synchronizers that rely on a single atomic int value to represent state.</p>
</blockquote>
<p>AQS 特性:</p>
<ul>
<li>阻塞等待队列</li>
<li>共享、独占</li>
<li>公平、非公平</li>
<li>可重入</li>
<li>允许中断</li>
</ul>
<p><img src="http://hitol.blog.cdn.updev.cn/2021-07-26-16272819971708.jpg" alt="" /></p>
<p>一般都是通过定义内部类 Sync 继承 AQS<br />
将同步器所有调用都映射到 Sync 对应的方法</p>
<p>AQS 内部维护属性 volatile int state 表示资源的可用状态</p>
<p>state 三种访问方式<br />
getState、setState、compareAndSetState</p>
<p>AQS 定义两种资源共享方式</p>
<ul>
<li>Exclusive,独占,只有一个线程能执行,如 ReentrantLock</li>
<li>Share,共享,多个线程可以同时执行,入 Semaphore、CountDownLatch</li>
</ul>
<p>AQS 定义两种队列</p>
<ul>
<li>同步等待队列</li>
<li>条件等待队列</li>
</ul>
<p>AQS,重点<br />
自旋、加锁(CAS)、LockSupport、队列</p>
<p>下面通过 ReentrantLock 看下 AQS 的实现。</p>
<h2><a id="reentrantlock" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>ReentrantLock</h2>
<p>ReentrantLock 内部 定义一个内部类 Sync,Sync 继承自 AQS,Sync 还有两个子类,FairSync、NonfairSync 区别公平锁与非公平锁。<br />
new ReentrantLock(true) 为公平锁<br />
构造函数:</p>
<pre class="line-numbers"><code class="language-java">// 默认非公平锁
public ReentrantLock() {
sync = new NonfairSync();
}
public ReentrantLock(boolean fair) {
sync = fair ? new FairSync() : new NonfairSync();
}
</code></pre>
<p>公平锁,按照线程过来的顺序依次去获取锁,FIFO<br />
非公平锁,可以插队</p>
<h3><a id="%E5%8A%A0%E9%94%81%E8%BF%87%E7%A8%8B" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>加锁过程</h3>
<p>假设现在 ReentrantLock 是 FairSync 公平锁</p>
<pre class="line-numbers"><code class="language-java">static final class FairSync extends Sync {
private static final long serialVersionUID = -3000897897090466540L;
// new ReentrantLock().lock() 会调用到这里
final void lock() {
acquire(1);
}
// acquire 在 AQS 的代码
// public final void acquire(int arg) {
// if (!tryAcquire(arg) && acquireQueued(addWaiter(Node.EXCLUSIVE), arg))
// selfInterrupt();
//}
protected final boolean tryAcquire(int acquires) {
final Thread current = Thread.currentThread();
// 先获取 state 的值
int c = getState();
// 这一步是 第一次加锁
// 如果 state 的值为 0,并且队列中没有等待的线程,并且 CAS 设置 state 值为1成功,执行 setExclusiveOwnerThread ,设置当前线程为 current,表示当前线程获得了锁
if (c == 0) {
if (!hasQueuedPredecessors() &&
compareAndSetState(0, acquires)) {
setExclusiveOwnerThread(current);
return true;
}
}
// 这一步是为了重入锁
// 如果 state 不是0,并且 AQS 中的当前执行线程就是当前线程,
// state + 1
else if (current == getExclusiveOwnerThread()) {
int nextc = c + acquires;
if (nextc < 0)
throw new Error("Maximum lock count exceeded");
setState(nextc);
return true;
}
// false 就是没有获得到锁,没有获取锁,会在执行 acquireQueued(addWaiter(Node.EXCLUSIVE), arg) 这个逻辑
return false;
}
}
</code></pre>
<p>当调用 ReentrantLock 的 lock 方法时会调用到 FairSync 类的 lock 方法。</p>
<p>acquire(1) 这个方法主要是加锁,然后设置 state 为 1,会先调用本类实现的 tryAcquire 方法 尝试去加锁,这个方法里面分为了第一次为当前线程加锁,和当前线程的重入锁两种情况,</p>
<p>如果是 state 为 0 ,hasQueuedPredecessors 方法,判断队列是否为空,或者当前线程是否是队列里第一个线程,<br />
如果队列为空,然后 CAS 比较并交换 state 的值为 1,这两步都成功了,则当前线程获取了锁,设置 AQS 内部的当前线程变量为 current。</p>
<p>如果 state 不是 0,判断 AQS 中的内部线程变量与 current 是否相等,是不是同一个线程来获取锁,是同一个线程,state + 1。可重入锁</p>
<p>如果当前线程没有获取锁,会执行 acquireQueued(addWaiter(Node.EXCLUSIVE), arg) 操作,将线程先添加队列,然后阻塞当前线程</p>
<p>Node.EXCLUSIVE 表示独占锁,addWaiter 这一步就是往队列里添加当前线程,添加到队列的尾部,Node 里有对当前线程的引用</p>
<pre class="line-numbers"><code class="language-java">private Node addWaiter(Node mode) {
// 新建 Node,绑定当前线程 与 独占模式
Node node = new Node(Thread.currentThread(), mode);
Node pred = tail;
// tail 为null,表示队列为空 ??tail 初始值是不是 null
// 不为 null,表示队列不为空,将 node 添加到队尾
if (pred != null) {
node.prev = pred;
if (compareAndSetTail(pred, node)) {
pred.next = node;
return node;
}
}
// 自旋,保证当前node 添加成功
enq(node);
return node;
}
private Node enq(final Node node) {
// 自旋 与 CAS 保证入队的线程 是一个一个入队的,原子性、同步
// 并且双向队列指针指向正确,此处也有并发情况,如果不是同步进行的有可能队列乱掉
for (;;) {
Node t = tail;
// 队列为空,表明是第一个线程进来,创建一个头结点,CAS 确保并发情况下只有一个线程能创建成功
// 设置头结点,尾结点等于头结点,相当于 初始化 队列,
// 但是没有对当前 node 操作,也就是说当前这个 node 还没有入队
if (t == null) { // Must initialize
if (compareAndSetHead(new Node()))
tail = head;
} else {
//队列不为空,添加到队尾
node.prev = t;
if (compareAndSetTail(t, node)) {
t.next = node;
return t;
}
}
}
}
</code></pre>
<p>addWaiter 方法中,第一个线程获取lock 的时候,tail应该是 null ,然后 enq 执行的时候,如果 tail 是 null,只是进行了初始化,并没有将 node 设置到队尾,在下一次循环的时候添加到队尾,这样就 head 就是头结点,然后第一个线程对应的 node 其实是第二个节点???</p>
<p>arg 就是 state,acquireQueued 这一步是为了阻塞队列中的线程,</p>
<pre class="line-numbers"><code class="language-java">final boolean acquireQueued(final Node node, int arg) {
boolean failed = true;
try {
boolean interrupted = false;
for (;;) {
// 当前 node 的前一个 node
final Node p = node.predecessor();
// 如果 p 是头结点,说明队列中只有一个node ,
// 则再去重试获取锁,如果获取成功了,当前线程就不用阻塞,直接执行
// 下一步 selfInterrupt 就不用执行,一定程度上提高了并发
if (p == head && tryAcquire(arg)) {
setHead(node);
p.next = null; // help GC
failed = false;
return interrupted;
}
// 判断 前置节点 p 的 waitStatus
if (shouldParkAfterFailedAcquire(p, node) &&
parkAndCheckInterrupt())
interrupted = true;
}
} finally {
if (failed)
cancelAcquire(node);
}
}
private static boolean shouldParkAfterFailedAcquire(Node pred, Node node) {
// 前置节点的 ws,等于这个 Node.SIGNAL 的时候,才可以阻塞当前调用线程
// 当前节点能否被 park 取决于其前置节点的 waitStatus
int ws = pred.waitStatus;
if (ws == Node.SIGNAL)
return true;
if (ws > 0) {
// 大于0 的就只有 CANCELLED,删除大于 0 的node
do {
node.prev = pred = pred.prev;
} while (pred.waitStatus > 0);
pred.next = node;
} else {
// 设置前置节点的状态为 Node.SIGNAL
compareAndSetWaitStatus(pred, ws, Node.SIGNAL);
}
return false;
}
private final boolean parkAndCheckInterrupt() {
// 阻塞当前调用线程
LockSupport.park(this);
// 返回线程中断状态,清除中断状态
return Thread.interrupted();
}
// 中断当前调用线程,上面的 parkAndCheckInterrupt 方法清理掉了线程的中断信号状态
static void selfInterrupt() {
// 中断线程
Thread.currentThread().interrupt();
}
</code></pre>
<p>Node 的 waitStatus<br />
CANCELLED = 1,表示已经失效的,需要删除<br />
SIGNAL = -1,表示可以被阻塞<br />
CONDITION = -2<br />
PROPAGATE = -3</p>
<p>shouldParkAfterFailedAcquire<br />
当前节点对应的线程是否要 park,取决于其前置节点的 waitStatus 的值,当是 -1 的时候返回 true,表示当前节点对应的线程可以被阻塞,<br />
如果是初始化状态,waitStatus = 0,则设置其前置节点的 waitStatus 为 -1。</p>
<h3><a id="reentrantlock-unlock%E8%A7%A3%E9%94%81%E8%BF%87%E7%A8%8B" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>ReentrantLock unlock 解锁过程</h3>
<p>unlock 会调用 release 方法。唤醒队列头部线程<br />
线程中断唤醒</p>
<pre class="line-numbers"><code class="language-java">
public final boolean release(int arg) {
// 尝试释放锁,修改 state 值为 原值减去 arg 的值
if (tryRelease(arg)) {
Node h = head;
// 头结点不为 null,并且头结点的 waitStatus 为 -1 时,才去 unpark 当前线程,然后把头结点的 waitStatus 改为 0
if (h != null && h.waitStatus != 0)
unparkSuccessor(h);
return true;
}
return false;
}
protected final boolean tryRelease(int releases) {
int c = getState() - releases;
if (Thread.currentThread() != getExclusiveOwnerThread())
throw new IllegalMonitorStateException();
boolean free = false;
if (c == 0) {
free = true;
setExclusiveOwnerThread(null);
}
setState(c);
return free;
}
// node 为头结点,头结点的 waitStatus = -1 时,执行该方法
// 将 头结点的 waitStatus 通过 CAS 方式 修改为 0
// unpark 头结点后面第一个 waitStatus <= 0 的节点对应的线程
private void unparkSuccessor(Node node) {
int ws = node.waitStatus;
if (ws < 0)
compareAndSetWaitStatus(node, ws, 0);
Node s = node.next;
if (s == null || s.waitStatus > 0) {
s = null;
for (Node t = tail; t != null && t != node; t = t.prev)
if (t.waitStatus <= 0)
s = t;
}
if (s != null)
LockSupport.unpark(s.thread);
}
</code></pre>
<p>上面加锁的过程,不惜循环两次,把头结点的 waitStatus 由 初始值 0 改为了 -1,<br />
解锁的过程又把头结点的 waitStatus 由 -1 改为 0</p>
<h3><a id="%E9%9D%9E%E5%85%AC%E5%B9%B3%E9%94%81" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>非公平锁</h3>
<pre class="line-numbers"><code class="language-java">static final class NonfairSync extends Sync {
private static final long serialVersionUID = 7316153563782823691L;
/**
* Performs lock. Try immediate barge, backing up to normal
* acquire on failure.
*/
final void lock() {
// 这里是插队,新来的线程是否能够立即获取到锁,
// 如果获取到则执行新来的线程,获取不到则添加到队列尾部
if (compareAndSetState(0, 1))
setExclusiveOwnerThread(Thread.currentThread());
else
acquire(1);
}
protected final boolean tryAcquire(int acquires) {
return nonfairTryAcquire(acquires);
}
}
final boolean nonfairTryAcquire(int acquires) {
final Thread current = Thread.currentThread();
int c = getState();
if (c == 0) {
// 与公平锁的区别 少了一步判断 !hasQueuedPredecessors()
if (compareAndSetState(0, acquires)) {
setExclusiveOwnerThread(current);
return true;
}
}
else if (current == getExclusiveOwnerThread()) {
int nextc = c + acquires;
if (nextc < 0) // overflow
throw new Error("Maximum lock count exceeded");
setState(nextc);
return true;
}
return false;
}
</code></pre>
<h2><a id="locksupport" class="anchor" aria-hidden="true"><span class="octicon octicon-link"></span></a>LockSupport</h2>
<p>当线程调用 LockSupport.park 方法后,线程会阻塞在这,有两种方式唤醒,<br />
一种是 外部唤醒,unpark<br />
另一种是线程中断</p>
<pre class="line-numbers"><code class="language-java">Thread t0 = new Thread(new Runnable() {
@Override
public void run() {
Thread thread = Thread.currentThread();
String name = thread.getName();
System.out.println( name + " 开始执行");
for (;;){
System.out.println("准备 park 当前线程 " + name);
LockSupport.park();
System.out.println("当前线程 " + name + " 已被唤醒");
if (thread.isInterrupted()){
System.out.println("线程已被中断");
return;
}
}
}
});
t0.start();
TimeUnit.SECONDS.sleep(2);
System.out.println("准备唤醒 " + t0.getName());
LockSupport.unpark(t0);
TimeUnit.SECONDS.sleep(2);
t0.interrupt();
--- 运行结果
Thread-0 开始执行
准备 park 当前线程 Thread-0
准备唤醒 Thread-0
当前线程 Thread-0 已被唤醒
准备 park 当前线程 Thread-0
当前线程 Thread-0 已被唤醒
线程已被中断
</code></pre>
<p>interrupt() 方法中断线程,但并不是立即停止线程,而是等待线程运行结束后中断</p>
<hr />
<!--
上面说完了 ReentrantLock,其实 AQS 还有两个比较重要的实现,CountDownLatch 和 Semaphore。
Semaphore 通常叫它信号量, 可以用来控制同时访问特定资源的线程数量。常用于限流。 比如:数据库连接池-->
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<span class="date">2021/07/26 14:46 下午</span>
<span>posted in </span>
<span class="posted-in"><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></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.html">« Prev Page</a>
</p>
</div>
<div class="large-6 columns">
<p class="text-right" style="padding-top:25px;">
<a href="Java_2.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>