- 浏览: 958528 次
文章分类
- 全部博客 (428)
- Hadoop (2)
- HBase (1)
- ELK (1)
- ActiveMQ (13)
- Kafka (5)
- Redis (14)
- Dubbo (1)
- Memcached (5)
- Netty (56)
- Mina (34)
- NIO (51)
- JUC (53)
- Spring (13)
- Mybatis (17)
- MySQL (21)
- JDBC (12)
- C3P0 (5)
- Tomcat (13)
- SLF4J-log4j (9)
- P6Spy (4)
- Quartz (12)
- Zabbix (7)
- JAVA (9)
- Linux (15)
- HTML (9)
- Lucene (0)
- JS (2)
- WebService (1)
- Maven (4)
- Oracle&MSSQL (14)
- iText (11)
- Development Tools (8)
- UTILS (4)
- LIFE (8)
最新评论
-
Donald_Draper:
Donald_Draper 写道刘落落cici 写道能给我发一 ...
DatagramChannelImpl 解析三(多播) -
Donald_Draper:
刘落落cici 写道能给我发一份这个类的源码吗Datagram ...
DatagramChannelImpl 解析三(多播) -
lyfyouyun:
请问楼主,执行消息发送的时候,报错:Transport sch ...
ActiveMQ连接工厂、连接详解 -
ezlhq:
关于 PollArrayWrapper 状态含义猜测:参考 S ...
WindowsSelectorImpl解析一(FdMap,PollArrayWrapper) -
flyfeifei66:
打算使用xmemcache作为memcache的客户端,由于x ...
Memcached分布式客户端(Xmemcached)
/* * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ */ package java.util; /** * A collection designed for holding elements prior to processing. * Besides basic {@link java.util.Collection Collection} operations, * queues provide additional insertion, extraction, and inspection * operations. Each of these methods exists in two forms: one throws * an exception if the operation fails, the other returns a special * value (either <tt>null</tt> or <tt>false</tt>, depending on the * operation). The latter form of the insert operation is designed * specifically for use with capacity-restricted <tt>Queue</tt> * implementations; in most implementations, insert operations cannot * fail. * Queue优先处理元素,除了Collection的基本操作之外,Queue添加了另外插入,拉取, 检查3个操作。每一种方法都有两种格式,一种操作失败,则抛出异常,另一种返回一个 特殊的值,null或false,依赖于操作。后一种形式的插入操作是用capacity-restricted Queue来实现的,在大多数的实现中,插入操作不会失败。 * <p> * <table BORDER CELLPADDING=3 CELLSPACING=1> * <tr> * <td></td> * <td ALIGN=CENTER>[i]Throws exception[/i]</td> * <td ALIGN=CENTER>[i]Returns special value[/i]</td> * </tr> * <tr> 插入,提供 * <td><b>Insert</b></td> * <td>{@link #add add(e)}</td> * <td>{@link #offer offer(e)}</td> * </tr> * <tr>移除,拉取 * <td><b>Remove</b></td> * <td>{@link #remove remove()}</td> * <td>{@link #poll poll()}</td> * </tr> * <tr>检查 * <td><b>Examine</b></td> * <td>{@link #element element()}</td> * <td>{@link #peek peek()}</td> * </tr> * </table> * * <p>Queues typically, but do not necessarily, order elements in a * FIFO (first-in-first-out) manner. Among the exceptions are * priority queues, which order elements according to a supplied * comparator, or the elements' natural ordering, and LIFO queues (or * stacks) which order the elements LIFO (last-in-first-out). * Whatever the ordering used, the [i]head[/i] of the queue is that * element which would be removed by a call to {@link #remove() } or * {@link #poll()}. In a FIFO queue, all new elements are inserted at * the [i] tail[/i] of the queue. Other kinds of queues may use * different placement rules. Every <tt>Queue</tt> implementation * must specify its ordering properties. * Queues除了非必要之外,元素的模式为FIFO。其中的一个例外是优先级队列,元素根据 比较器或者本身的顺序添加队列( LIFO queues)中。无论什么顺序,对头的元素将会 被#remove或#poll消费/移除。在先进先出队列中,所有的新元素插入到队尾,其他队列 可能会用其他的策略添加新元素。每一种队列的实现要明确排序策略。 * <p>The {@link #offer offer} method inserts an element if possible, * otherwise returning <tt>false</tt>. This differs from the {@link * java.util.Collection#add Collection.add} method, which can fail to * add an element only by throwing an unchecked exception. The * <tt>offer</tt> method is designed for use when failure is a normal, * rather than exceptional occurrence, for example, in fixed-capacity * (or "bounded") queues. * 如果可能,offer操作,插入元素时,会返回false。这个与集合类的add方法不同的时, 集合类add方法,当失败时,则抛出一个unchecked异常。offer操作设计为在一个正常模式下的失败, 而不异常发生,比如队列容量有限。 * <p>The {@link #remove()} and {@link #poll()} methods remove and * return the head of the queue. * Exactly which element is removed from the queue is a * function of the queue's ordering policy, which differs from * implementation to implementation. The <tt>remove()</tt> and * <tt>poll()</tt> methods differ only in their behavior when the * queue is empty: the <tt>remove()</tt> method throws an exception, * while the <tt>poll()</tt> method returns <tt>null</tt>. * * <p>The {@link #element()} and {@link #peek()} methods return, but do * not remove, the head of the queue. * remove和poll元素将从队列头部消费一个元素。不同的队列实现消费队列元素顺序时,可能有不同的 策略。remove和poll操作不同的时,当队列为空时,remove抛出异常 ,poll则返回null。 * <p>The <tt>Queue</tt> interface does not define the <i>blocking queue * methods</i>, which are common in concurrent programming. These methods, * which wait for elements to appear or for space to become available, are * defined in the {@link java.util.concurrent.BlockingQueue} interface, which * extends this interface. * Queue没有定义阻塞队列的方法,这些方法会在并发编程中用到。这些方法,比如,在队列为空时, 消费者阻塞等待队列有元素可利用,这些方法在BlockingQueue接口中定义。 * <p><tt>Queue</tt> implementations generally do not allow insertion * of <tt>null</tt> elements, although some implementations, such as * {@link LinkedList}, do not prohibit insertion of <tt>null</tt>. * Even in the implementations that permit it, <tt>null</tt> should * not be inserted into a <tt>Queue</tt>, as <tt>null</tt> is also * used as a special return value by the <tt>poll</tt> method to * indicate that the queue contains no elements. 队列的实现通常不允许插入null,尽管LinkedList不禁止插入null值。即使允许插入null, 我们也利用利用poll操作,来暗示队列中没有元素。 * * <p><tt>Queue</tt> implementations generally do not define * element-based versions of methods <tt>equals</tt> and * <tt>hashCode</tt> but instead inherit the identity based versions * from class <tt>Object</tt>, because element-based equality is not * always well-defined for queues with the same elements but different * ordering properties. * Queue的实现通常不会定义equals和hashCode方法,而是继承自Object,因为hash值和值相等 ,但是顺序属性可能不同。 * * <p>This interface is a member of the * <a href="{@docRoot}/../technotes/guides/collections/index.html"> * Java Collections Framework</a>. * * @see java.util.Collection * @see LinkedList * @see PriorityQueue * @see java.util.concurrent.LinkedBlockingQueue * @see java.util.concurrent.BlockingQueue * @see java.util.concurrent.ArrayBlockingQueue * @see java.util.concurrent.LinkedBlockingQueue * @see java.util.concurrent.PriorityBlockingQueue * @since 1.5 * @author Doug Lea * @param <E> the type of elements held in this collection */ public interface Queue<E> extends Collection<E> { /** * Inserts the specified element into this queue if it is possible to do so * immediately without violating capacity restrictions, returning * <tt>true</tt> upon success and throwing an <tt>IllegalStateException</tt> * if no space is currently available. * 在有界队列未满的情况下,添加元素,返回true,没空间可利用,则抛出异常IllegalStateException * @param e the element to add * @return <tt>true</tt> (as specified by {@link Collection#add}) * @throws IllegalStateException if the element cannot be added at this * time due to capacity restrictions * @throws ClassCastException if the class of the specified element * prevents it from being added to this queue * @throws NullPointerException if the specified element is null and * this queue does not permit null elements * @throws IllegalArgumentException if some property of this element * prevents it from being added to this queue */ boolean add(E e); /** * Inserts the specified element into this queue if it is possible to do * so immediately without violating capacity restrictions. * When using a capacity-restricted queue, this method is generally * preferable to {@link #add}, which can fail to insert an element only * by throwing an exception. * 在有界队列未满的情况下,添加元素,立即成功;当队列为有界是,add更好,因为越界抛出异常 * @param e the element to add * @return <tt>true</tt> if the element was added to this queue, else * <tt>false</tt> * @throws ClassCastException if the class of the specified element * prevents it from being added to this queue * @throws NullPointerException if the specified element is null and * this queue does not permit null elements * @throws IllegalArgumentException if some property of this element * prevents it from being added to this queue */ boolean offer(E e); /** * Retrieves and removes the head of this queue. This method differs * from {@link #poll poll} only in that it throws an exception if this * queue is empty. * 从对头消费一个元素,当队列为空,抛出异常 * @return the head of this queue * @throws NoSuchElementException if this queue is empty */ E remove(); /** * Retrieves and removes the head of this queue, * or returns <tt>null</tt> if this queue is empty. * 从对头消费一个元素,当队列为空,返回null * @return the head of this queue, or <tt>null</tt> if this queue is empty */ E poll(); /** * Retrieves, but does not remove, the head of this queue. This method * differs from {@link #peek peek} only in that it throws an exception * if this queue is empty. * 检查队列中是否有元素,当队列为空,抛出异常 * @return the head of this queue * @throws NoSuchElementException if this queue is empty */ E element(); /** * Retrieves, but does not remove, the head of this queue, * or returns <tt>null</tt> if this queue is empty. * 检查队列中是否有元素,当队列为空,返回null * @return the head of this queue, or <tt>null</tt> if this queue is empty */ E peek(); }
附:Collection
发表评论
-
Executors解析
2017-04-07 14:38 1210ThreadPoolExecutor解析一(核心线程池数量、线 ... -
ScheduledThreadPoolExecutor解析三(关闭线程池)
2017-04-06 20:52 4422ScheduledThreadPoolExecutor解析一( ... -
ScheduledThreadPoolExecutor解析二(任务调度)
2017-04-06 12:56 2082ScheduledThreadPoolExecutor解析一( ... -
ScheduledThreadPoolExecutor解析一(调度任务,任务队列)
2017-04-04 22:59 4933Executor接口的定义:http://donald-dra ... -
ThreadPoolExecutor解析四(线程池关闭)
2017-04-03 23:02 9048Executor接口的定义:http: ... -
ThreadPoolExecutor解析三(线程池执行提交任务)
2017-04-03 12:06 6039Executor接口的定义:http://donald-dra ... -
ThreadPoolExecutor解析二(线程工厂、工作线程,拒绝策略等)
2017-04-01 17:12 3003Executor接口的定义:http://donald-dra ... -
ThreadPoolExecutor解析一(核心线程池数量、线程池状态等)
2017-03-31 22:01 20472Executor接口的定义:http://donald-dra ... -
ScheduledExecutorService接口定义
2017-03-29 12:53 1462Executor接口的定义:http://donald-dra ... -
AbstractExecutorService解析
2017-03-29 08:27 1033Executor接口的定义:http: ... -
ExecutorCompletionService解析
2017-03-28 14:27 1539Executor接口的定义:http://donald-dra ... -
CompletionService接口定义
2017-03-28 12:39 1017Executor接口的定义:http://donald-dra ... -
FutureTask解析
2017-03-27 12:59 1291package java.util.concurrent; ... -
Future接口定义
2017-03-26 09:40 1142/* * Written by Doug Lea with ... -
ExecutorService接口定义
2017-03-25 22:14 1123Executor接口的定义:http://donald-dra ... -
Executor接口的定义
2017-03-24 23:24 1612package java.util.concurrent; ... -
简单测试线程池拒绝执行任务策略
2017-03-24 22:37 1971线程池多余任务的拒绝执行策略有四中,分别是直接丢弃任务Disc ... -
JAVA集合类简单综述
2017-03-23 22:51 887Queue接口定义:http://donald-draper. ... -
DelayQueue解析
2017-03-23 11:00 1690Queue接口定义:http://donald-draper. ... -
SynchronousQueue解析下-TransferQueue
2017-03-22 22:20 2098Queue接口定义:http://donald-draper. ...
相关推荐
文章目录简介Queue接口Queue的分类BlockingQueueDequeTransferQueue总结 java中Queue家族简介 简介 java中Collection集合有三大家族List,Set和Queue。当然Map也算是一种集合类,但Map并不继承Collection接口。 List...
主要介绍Queue的相关知识,包括Queue的定义,发送和接收消息的方式等内容。重点使用Free RTOS中Queue的接口,实现数据在不同task之间的发送和接收的案例,并在板卡上验证该功能。
(完整项目,可直接食用)Java提供的java.util.Queue是一个接口没有构造函数。试用java.util.Stack泛型栈作为父类,用另一...除提供无参构造函数Queue( )外,其它所有队列函数严格参照java.util.Queue的接口定义实现。
Collection接口是List、Set和Queue接口的父接口,定义了存取一组对象的方法。Collection接口继承自Iterable接口,这意味着可以通过for-each循环遍历集合元素。 List接口是有序的集合,可以包含重复的元素。List接口...
为了将此应用程序安装到您本地的 ArangoDB,您可以像这样使用 Foxx-manager foxx-manager install queue-it /queue这会将应用程序下载到 ArangoDB 的本地安装(必须已启动并运行)并将其安装在路径“/queue”下。...
PHP JobQueue组件 简单的Job / Queue PHP组件,可帮助应用程序通过多个工作程序分发任务。安装该软件包可通过Composer安装并自动加载: $ ... 必须在实现ExecutableJob接口PHP类中定义每个作业: <?phpuse JobQ
[问题描述] 设停车厂只有一个可停放几辆汽车的狭长通道,且只有—个大门可供汽车进出。汽车在停车场内按车辆到达的先后顺序依次排列,若...3.定义Queue接口 4.设计等待队列WaitQueue 5.定义结点类Node 6.搭建管理界面
9. 使用Java集合类实现队列:演示了如何使用Java集合类中的Queue接口来实现队列数据结构。 10. 多线程编程:创建和启动线程:展示了如何通过实现Runnable接口创建一个新线程,并演示了多线程编程的基本概念。
一般我们比较少接触MessageQueue, 其实它内部的IdleHandler接口有很多有趣的用法,首先看看它的定义: 简而言之,就是在looper里面的message暂时处理完了,这个时候会回调这个接口,返回false,那么就会移除它,...
定义IRPC接口用来处理同步调用的被调用端 定义Bind函数用来绑定IRPC接口的实例 定义CallEx函数用来实现用户同步调用 2.3 添加bInit变量,用于设置初始化和关闭状态。 设置此变量的目的主要是用来控制,在关闭了...
msqueue_config_loader 定义消息队列配置结构并实现LoadByFile和LoadByBytes接口。 type QueueConfig struct {Url string `json:"url" yaml:"url"`AccessKeyId string `json:"access_key_id" yaml:"access_key_id"`...
优先队列(priority_queue)和一般队列(queue)的函数接口一致,不同的是,优先队列每次出列的是整个队列中最小(或者最大)的元素。 本文简要介绍一种基于数组二叉堆实现的优先队列,定义的数据结构和实现的函数接口...
发送和接收接口定义在/include/linux/netdevice.h中。函数原型:int dev_queue_xmit(struct sk_buff* skb); int netif_rx(struct sk_buff* skb); 其中sk_buff含义为套接字缓冲区,定义在/include/linux/skbuff.h中。...
这些代码定义在(/linux/net/core/dev.c)文件中,其中两个主要函数是 deb_queue_xmit 和 netif_rx。相邻层的通信通过这些函数调用实现,降低了开发难度,使得层间通信更容易理解。 1.3 几个常用的接口例程 * 初始...
这些操作使LinkedList可被用作堆栈(stack)、队列(queue)或双向队列(deque)。 ArrayList类实现了可变大小的数组。它允许所有元素,包括null。ArrayList没有同步。size、isEmpty、get、set方法运行时间为常数。...
简单地说就是一种接口类,专门用来修改现有类的接口,提供一种新的接口;或调用现有的函数来实现所需要的功能。 主要包括3种适配器Container Adaptors、Iterator Adaptors与Function Adaptors。其中迭代器适配器...
HAL 层提供了一些公共的接口,用于访问硬件设备。HAL 层开发需要实现设备的初始化、操作和释放等功能。 BMA250 功能描述 BMA250 是一款加速度传感器,用于测量加速度和orientation。BMA250 的功能包括电源管理、...
Notification发送者可以自己定义设置发送的Queue,自己灵活处理阻塞,超时等问题。 Example: 更多的例子在src/test/java 目录下。 public class MainExample { public static void main...
16.2.7 队列集合:Queue 455 16.2.8 链表:LinkedList 456 16.3 提供索引器 456 16.4 返回null或者空集合 459 16.5 迭代器 459 16.5.1 迭代器的定义 460 16.5.2 迭代器语法 460 16.5.3 ...