[英]What is the use of ConcurrentLinkedQueue?
I am working in bluetooth in android kotlin. I found this blessed library and this class BluetoothPeripheral is using ConcurrentLinkedQueue
.我在 android kotlin 从事蓝牙工作。我找到了这个有福的图书馆,而这个 class BluetoothPeripheral正在使用
ConcurrentLinkedQueue
。 I don't understand what is the use of我不明白有什么用
private val commandQueue: Queue<Runnable> = ConcurrentLinkedQueue()
I am looking this enqueue function and I cannot understand the use case in here.我正在查看这个enqueue function,我无法理解这里的用例。 what the author trying to achieved in here?
作者在这里想达到什么目的?
This enqueue function calls in different place ie readCharacteristic what is the use case in this function?这个enqueue function 在不同的地方调用,即readCharacteristic这个 function 的用例是什么?
Thanks谢谢
Building on @broot's comment:基于@broot 的评论:
ConcurrentLinkedQueue
is part of the java.util.concurrent
package which is all about collections that are thread-safe ConcurrentLinkedQueue
是java.util.concurrent
package 的一部分,它是线程安全的 collectionsQueue
is a kind of collection that is designed for efficient adding and removal. Queue
是一种专为高效添加和删除而设计的集合。 Typically they offer First In First Out.ConcurrentLinkedQueue
ConcurrentLinkedQueue
ConcurrentLinkedQueue
is based on a Linked List so typically have have far greater capacity, but mean that some operations, such as search might perform less well.ConcurrentLinkedQueue
这样的队列基于链表,因此通常具有更大的容量,但这意味着某些操作(例如搜索)可能执行得不太好。Dequeue
which is a Queue
that you can remove items easily from both ends.Dequeue
,它是一个Queue
,您可以轻松地从两端删除项目。 I have no idea what the Bluetooth application is about and why it needs ConcurrentLinkedQueue
so I cannot comment on whether it is the "best options to use in bluetooth case"我不知道蓝牙应用程序是关于什么的,也不知道它为什么需要
ConcurrentLinkedQueue
,所以我无法评论它是否是“在蓝牙情况下使用的最佳选择”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.