Skip to content

Commit 664902b

Browse files
author
likongpeng
committed
修改一些注释
1 parent 5054023 commit 664902b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<parent>
6-
<artifactId>bos-ability</artifactId>
7-
<groupId>com.youzan</groupId>
8-
<version>1.0-SNAPSHOT</version>
9-
<relativePath>../bos-ability/pom.xml</relativePath>
10-
</parent>
11-
<modelVersion>4.0.0</modelVersion>
125

6+
<modelVersion>4.0.0</modelVersion>
137
<artifactId>java</artifactId>
8+
<groupId>java</groupId>
9+
<version>1.0.0</version>
1410
<packaging>pom</packaging>
1511

12+
<build>
13+
<pluginManagement>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-source-plugin</artifactId>
18+
<version>3.0.1</version>
19+
</plugin>
20+
</plugins>
21+
</pluginManagement>
22+
</build>
1623
</project>

src/main/java/java/util/ArrayList.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ public boolean add(E e) {
444444
}
445445
private void ensureCapacityInternal(int minCapacity) {
446446
//如果是空数组,就从最小容量和默认容量10之间取最大值
447-
//所以当你在初始化数组大小时,如果你给定的初始化大小是 5,最终其实会初始化大小其实为 10
448447
if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {
449448
minCapacity = Math.max(DEFAULT_CAPACITY, minCapacity);
450449
}

src/main/java/java/util/concurrent/ArrayBlockingQueue.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ public boolean offer(E e) {
356356
* @throws InterruptedException {@inheritDoc}
357357
* @throws NullPointerException {@inheritDoc}
358358
*/
359+
// 新增,如果队列满,无限阻塞
359360
public void put(E e) throws InterruptedException {
361+
// 元素不能为空
360362
checkNotNull(e);
361363
final ReentrantLock lock = this.lock;
362364
lock.lockInterruptibly();
@@ -372,7 +374,7 @@ public void put(E e) throws InterruptedException {
372374
}
373375

374376
private void enqueue(E x) {
375-
// assert lock.getHoldCount() == 1;
377+
// assert lock.getHoldCount() == 1; 同一时刻只能一个线程进行操作此方法
376378
// assert items[putIndex] == null;
377379
final Object[] items = this.items;
378380
// putIndex 为本次插入的位置

src/main/java/java/util/concurrent/Executors.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory thr
169169
*/
170170
public static ExecutorService newSingleThreadExecutor() {
171171
return new FinalizableDelegatedExecutorService
172+
// 前两个参数规定了这个线程池一次只能消费一个线程
173+
// 第五个参数使用的是 LinkedBlockingQueue,说明当请求超过单线程消费能力时,就会排队
172174
(new ThreadPoolExecutor(1, 1,
173175
0L, TimeUnit.MILLISECONDS,
174176
new LinkedBlockingQueue<Runnable>()));

0 commit comments

Comments
 (0)