Java中的ConcurrentLinkedDeque
Java中的ConcurrentLinkedDeque类实现了双端队列,并使用了并发链接列表来寻求帮助。此类实现Collection接口以及AbstractCollection类。它是JavaCollectionFramework的一部分。
演示此的程序如下所示-
示例
import java.util.concurrent.*;
public class Demo {
public static void main(String[] args) {
ConcurrentLinkedDeque<String> clDeque = new ConcurrentLinkedDeque<String>();
clDeque.add("James");
clDeque.add("May");
clDeque.add("John");
clDeque.add("Sara");
clDeque.add("Anne");
System.out.println("The elements in ConcurrentLinkedDeque are: " + clDeque);
}
}上面程序的输出如下-
输出结果
The elements in ConcurrentLinkedDeque are: [James, May, John, Sara, Anne]
现在让我们了解上面的程序。
创建ConcurrentLinkedDeque,然后将元素添加到Deque的前面。最后,显示元素。证明这一点的代码片段如下-
ConcurrentLinkedDeque<String> clDeque = new ConcurrentLinkedDeque<String>();
clDeque.add("James");
clDeque.add("May");
clDeque.add("John");
clDeque.add("Sara");
clDeque.add("Anne");
System.out.println("The elements in ConcurrentLinkedDeque are: " + clDeque);热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语