mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Merge pull request #2152 from cxhello/main
Update delayqueue-source-code.md
This commit is contained in:
commit
43e1fd4f52
@ -115,7 +115,7 @@ Task 3
|
||||
|
||||
## DelayQueue 源码解析
|
||||
|
||||
这里以 JDK1.8 为例,分析一下 `LinkedList` 的底层核心源码。
|
||||
这里以 JDK1.8 为例,分析一下 `DelayQueue` 的底层核心源码。
|
||||
|
||||
`DelayQueue` 的类定义如下:
|
||||
|
||||
@ -126,7 +126,7 @@ public class DelayQueue<E extends Delayed> extends AbstractQueue<E> implements B
|
||||
}
|
||||
```
|
||||
|
||||
`DelayQueue` 实现了 `AbstractQueue` 类,继承了 `BlockingQueue` 接口。
|
||||
`DelayQueue` 继承了 `AbstractQueue` 类,实现了 `BlockingQueue` 接口。
|
||||
|
||||

|
||||
|
||||
|
@ -215,7 +215,7 @@ static final class RunnableAdapter<T> implements Callable<T> {
|
||||
工厂模式用于创建对象,NIO 中大量用到了工厂模式,比如 `Files` 类的 `newInputStream` 方法用于创建 `InputStream` 对象(静态工厂)、 `Paths` 类的 `get` 方法创建 `Path` 对象(静态工厂)、`ZipFileSystem` 类(`sun.nio`包下的类,属于 `java.nio` 相关的一些内部实现)的 `getPath` 的方法创建 `Path` 对象(简单工厂)。
|
||||
|
||||
```java
|
||||
InputStream is Files.newInputStream(Paths.get(generatorLogoPath))
|
||||
InputStream is = Files.newInputStream(Paths.get(generatorLogoPath))
|
||||
```
|
||||
|
||||
## 观察者模式
|
||||
|
Loading…
x
Reference in New Issue
Block a user