LinkedBlockingQueue
作者:
chrisghb | 来源:发表于
2022-08-13 16:43 被阅读0次// 一个阻塞的线程安全的队列
private LinkedBlockingQueue<ErrorMsgVO> errorDevMsgs = new LinkedBlockingQueue<>();
if (errorDevMsgs.isEmpty()) {
}
Iterator<ErrorMsgVO> it = errorDevMsgs.iterator();
while (it.hasNext()) {
ErrorMsgVO t = it.next();
}
方法 |
说明 |
解释 |
add |
增加一个元索 |
如果队列已满,则抛出一个IIIegaISlabEepeplian异常 |
offer |
添加一个元素并返回true |
如果队列已满,则返回false |
put |
添加一个元素 |
如果队列已满,则阻塞 |
|
poll |
移除并返问队列头部的元素 |
如果队列为空,则返回null |
remove |
移除并返回队列头部的元素 |
如果队列为空,则抛出一个NoSuchElementException异常 |
peek |
返回队列头部的元素 |
如果队列为空,则返回null |
element |
返回队列头部的元素 |
如果队列为空,则抛出一个NoSuchElementException异常 |
take |
移除并返回队列头部的元素 |
如果队列为空,则阻塞 |
本文标题:LinkedBlockingQueue
本文链接:https://www.haomeiwen.com/subject/epnzbrtx.html
网友评论