Java中的ConcurrentLinkedQueue
Java中的ConcurrentLinkedQueue类用于使用并发链表实现队列。此类实现Collection接口以及AbstractCollection类。它是JavaCollectionFramework的一部分。
演示此的程序如下所示-
示例
import java.util.concurrent.*;
public class Demo {
public static void main(String[] args) {
ConcurrentLinkedQueue<String> clQueue = new ConcurrentLinkedQueue<String>();
clQueue.add("Amy");
clQueue.add("John");
clQueue.add("May");
clQueue.add("Harry");
clQueue.add("Anne");
System.out.println("The elements in ConcurrentLinkedQueue are: " + clQueue);
}
}上面程序的输出如下-
输出结果
The elements in ConcurrentLinkedQueue are: [Amy, John, May, Harry, Anne]
现在让我们了解上面的程序。
创建ConcurrentLinkedQueue,然后将元素添加到其中。最后,它被显示。证明这一点的代码片段如下-
ConcurrentLinkedQueue<String> clQueue = new ConcurrentLinkedQueue<String>();
clQueue.add("Amy");
clQueue.add("John");
clQueue.add("May");
clQueue.add("Harry");
clQueue.add("Anne");
System.out.println("The elements in ConcurrentLinkedQueue are: " + clQueue);热门推荐
10 同事离别祝福语简短的
11 早日回国祝福语简短英语
12 上班收到花束祝福语简短
13 三十三句祝福语简短
14 农民朋友发财祝福语简短
15 婆婆高寿祝福语大全简短
16 老师开工仪式祝福语简短
17 迎接朋友蛋糕祝福语简短
18 女神结婚快乐祝福语简短