久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

java DelayQueue的原理淺析

瀏覽:2日期:2022-08-18 15:19:38

在對DelayQueue延遲功能的使用上,很多人不能后完全理解延遲的一些功能使用,這里我們深入來挖掘一下DelayQueue的原理。

下面將從構(gòu)造方法、接口、繼承體系三個方面進行分析,需要注意的是,相較于其它的阻塞隊列,DelayQueue因為延遲的功能多了接口的使用,一起來看具體內(nèi)容。

1.構(gòu)造方法

public DelayQueue() {}public DelayQueue(Collection<? extends E> c) { this.addAll(c);}

構(gòu)造方法比較簡單,一個默認(rèn)構(gòu)造方法,一個初始化添加集合c中所有元素的構(gòu)造方法。

2.接口分析

public interface Delayed extends Comparable<Delayed> { /** * Returns the remaining delay associated with this object, in the * given time unit. * * @param unit the time unit * @return the remaining delay; zero or negative values indicate * that the delay has already elapsed */ long getDelay(TimeUnit unit);}

Delayed 接口有一個getDelay方法接口,該方法用來告知延遲到期有多長的時間,或者延遲在多長時間之前已經(jīng)到期,是不是很簡單。

為了排序Delayed 接口還繼承了Comparable 接口,因此必須實現(xiàn)compareTo(),使其可以進行元素的比較。

3.繼承體系

java DelayQueue的原理淺析

public class DelayQueue<E extends Delayed>extends AbstractQueue<E>implements BlockingQueue<E>

到此這篇關(guān)于java DelayQueue的原理淺析的文章就介紹到這了,更多相關(guān)java DelayQueue的原理內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Java
相關(guān)文章:
主站蜘蛛池模板: 嘉禾县| 沂水县| 根河市| 巴青县| 绥化市| 姚安县| 崇信县| 句容市| 天等县| 普兰店市| 专栏| 西昌市| 柘荣县| 麦盖提县| 广丰县| 七台河市| 安多县| 万宁市| 西城区| 安化县| 龙州县| 奎屯市| 托克逊县| 大田县| 淮北市| 财经| 海口市| 陆川县| 阜新| 泉州市| 武宣县| 伊吾县| 准格尔旗| 松潘县| 正定县| 修武县| 长治市| 张家界市| 桃源县| 张北县| 穆棱市|