当前位置: 首页 > news >正文

创建网站目录权限/简述优化搜索引擎的方法

创建网站目录权限,简述优化搜索引擎的方法,网站后台编辑怎么做,上海大型网站制作先看类简介: /*** 生产者可以等待消费者接收元素,当消息在应用传递时,生产者通过 transfer()等待消费者调用 take()/poll()来接收元素,很有用。在其他时候,通过put()可以不等待接收。* tryTransfer()/tryTransfer(Obj…

先看类简介:

/*** 生产者可以等待消费者接收元素,当消息在应用传递时,生产者通过 transfer()等待消费者调用 take()/poll()来接收元素,很有用。在其他时候,通过put()可以不等待接收。* tryTransfer()/tryTransfer(Object) Non-blocking()/tryTransfer(Object,long,TimeUnit) time-out版本也可用。* 也可以通过hasWaitingConsumer()来查询是否有线程在等待元素,这与peek()操作相反。 * A {@link BlockingQueue} in which producers may wait for consumers* to receive elements.  A {@code TransferQueue} may be useful for* example in message passing applications in which producers* sometimes (using method {@link #transfer}) await receipt of* elements by consumers invoking {@code take} or {@code poll}, while* at other times enqueue elements (via method {@code put}) without* waiting for receipt.* {@linkplain #tryTransfer(Object) Non-blocking} and* {@linkplain #tryTransfer(Object,long,TimeUnit) time-out} versions of* {@code tryTransfer} are also available.* A {@code TransferQueue} may also be queried, via {@link* #hasWaitingConsumer}, whether there are any threads waiting for* items, which is a converse analogy to a {@code peek} operation.** 就像其他的阻塞队列,TransferQueue也可能有容量限制.如果这样,尝试的传输操作可能首先阻塞对可用空间的等待,并且/或随后阻塞对消费者接收的等待。* 注意,在一个容量为零的队列中,例如{@link SynchronousQueue}, {@code put}和{@code transfer}实际上是同义的。 * <p>Like other blocking queues, a {@code TransferQueue} may be* capacity bounded.  If so, an attempted transfer operation may* initially block waiting for available space, and/or subsequently* block waiting for reception by a consumer.  Note that in a queue* with zero capacity, such as {@link SynchronousQueue}, {@code put}* and {@code transfer} are effectively synonymous.** <p>This interface is a member of the* <a href="{@docRoot}/../technotes/guides/collections/index.html">* Java Collections Framework</a>.** @since 1.7* @author Doug Lea* @param <E> the type of elements held in this collection*/

从类简介中可知两点:

1、生产者通过 transfer()等待消费者调用 take()/poll()来接收元素,如果消费者没有获取元素,那么当此入队操作就是一次失败的入队操作。

2、SynchronousQueue 是一个容量为0的BlockingQueue队列,并非是TransferQueue队列,但它的put()和TransferQueue中的transfer()操作是同义的。

看类源码实现:

public interface TransferQueue<E> extends BlockingQueue<E> {/*** 等待 consumer之后,立马开始传输一个文件。* Transfers the element to a waiting consumer immediately, if possible.** 更严格来说,如果存在一个用户通过take()或者定时poll(),已经在等待接收,可以立马进行元素传输。否认元素没有入队列,并返回false.* 如果被添加的元素,阻止其被添加到队列中,返回false。* <p>More precisely, transfers the specified element immediately* if there exists a consumer already waiting to receive it (in* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),* otherwise returning {@code false} without enqueuing the element.** @param e the element to transfer* @return {@code true} if the element was transferred, else*         {@code false}* @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* @throws IllegalArgumentException if some property of the specified*         element prevents it from being added to this queue*/boolean tryTransfer(E e);/*** 如果需要的话,给消费者传递一个元素。* Transfers the element to a consumer, waiting if necessary to do so.** 更严格来说,如果存在一个用户通过take()或者定时poll(),已经在等待接收,可以立马进行元素传输。否则一直等待直到元素被消费者接收。* <p>More precisely, transfers the specified element immediately* if there exists a consumer already waiting to receive it (in* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),* else waits until the element is received by a consumer.** @param e the element to transfer* @throws InterruptedException if interrupted while waiting,*         in which case the element is not left enqueued* @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* @throws IllegalArgumentException if some property of the specified*         element prevents it from being added to this queue*/void transfer(E e) throws InterruptedException;/*** 在超时之前,如果可能的话,给消费者传递一个元素* Transfers the element to a consumer if it is possible to do so* before the timeout elapses.** 在元素被传递之前,等待指定的时间,超时则返回false。* <p>More precisely, transfers the specified element immediately* if there exists a consumer already waiting to receive it (in* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),* else waits until the element is received by a consumer,* returning {@code false} if the specified wait time elapses* before the element can be transferred.** @param e the element to transfer* @param timeout how long to wait before giving up, in units of*        {@code unit}* 等待时间的单位* @param unit a {@code TimeUnit} determining how to interpret the*        {@code timeout} parameter* 成功的话返回true,否则返回false,此时元素没有离开队列。* @return {@code true} if successful, or {@code false} if*         the specified waiting time elapses before completion,*         in which case the element is not left enqueued* 等待的时候被打断,抛出 InterruptedException异常,此时元素没有离开队列。* @throws InterruptedException if interrupted while waiting,*         in which case the element is not left enqueued* 如果指定的元素拒绝被插入队列,抛出 ClassCastException异常。* @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* 如果指定元素的部分属性,拒绝被插入队列,抛出 IllegalArgumentException异常。* @throws IllegalArgumentException if some property of the specified*         element prevents it from being added to this queue*/boolean tryTransfer(E e, long timeout, TimeUnit unit)throws InterruptedException;/*** 如果至少有一个消费者通过take()/定时poll()在等待接收元素,返回事务瞬时状态值(true)* Returns {@code true} if there is at least one consumer waiting* to receive an element via {@link #take} or* timed {@link #poll(long,TimeUnit) poll}.* The return value represents a momentary state of affairs.** @return {@code true} if there is at least one waiting consumer*/boolean hasWaitingConsumer();/*** 返回正在通过take/定时poll接收元素的消费者预估数量。返回值是瞬时状态的预估值,如果消费者完成或放弃等待,该值可能不准确。* 该值作为监控和探索可能比较有用,但是不能作为同步控制。该方法实现,明显比 hasWaitingConsumer()慢。* Returns an estimate of the number of consumers waiting to* receive elements via {@link #take} or timed* {@link #poll(long,TimeUnit) poll}.  The return value is an* approximation of a momentary state of affairs, that may be* inaccurate if consumers have completed or given up waiting.* The value may be useful for monitoring and heuristics, but* not for synchronization control.  Implementations of this* method are likely to be noticeably slower than those for* {@link #hasWaitingConsumer}.** @return the number of consumers waiting to receive elements*/int getWaitingConsumerCount();
}

 tryTransfer():会立马返回结果,如果成功,就返回true,失败返回false;

 transfer():会等待元素被消费者取走

tryTransfer(E e, long timeout, TimeUnit unit):在指定的时间内等待元素被消费者接收,否则返回false;

getWaitingConsumerCount():该方法只是一个大概的估计值,作为监控比较有用,但是不能作为同步的依据,并且会比hasWaitingConsumer()慢。

 

http://www.jmfq.cn/news/4877551.html

相关文章:

  • 淄博高端网站建设/图片识别 在线百度识图
  • 从搜索引擎访问网站/搜索引擎优化是什么?
  • 枣庄做网站公司/站长素材官网
  • 这个网站中有网名做会计的吗 了解一下/网站快速排名互点软件
  • 自己如何开发一个小程序/seo推广怎么做
  • 网站设计公司/中国十大网站有哪些
  • win7如何安装iis来浏览asp网站/每天新闻早知道
  • 政府网站群四种建设模式/学生个人网页制作代码
  • 做企业网站接单/班级优化大师免费下载学生版
  • 火星建站和八亿建站/网站流量排名
  • 2020年注册公司流程和费用/常德seo快速排名
  • 哈尔滨网站建设可信赖/网络运营和网络营销的区别
  • 企业网站建设存在的问题及建议/百度手机助手下载免费安装
  • 偷网站源码直接建站/手机如何制作网站教程
  • 做网站月薪资多少钱/2024年的新闻时事热点论文
  • 做搜狗手机网站优化快/公司网络搭建
  • 鹤壁哪有做网站的/品牌建设的五个要素
  • 注册网站建设公司/企业策划书
  • 自助做网站傻瓜式自助建站工具/如何推广小程序平台
  • 长春朝阳网站建设/线上广告推广
  • 新昌网站制作/集客营销软件官方网站
  • 可以直接做ppt的网站/种子搜索神器 bt 下载
  • 有公司可以做网站升级ipv6/官方网站怎么注册
  • 手机网站营销方法/百度搜索量查询
  • 上海做公司网站的公司/百度竞价推广账户优化
  • 建筑模板怎么装/淄博网站seo
  • 告诉你做网站需要多少钱/免费推广方法
  • 域名打不开原来的网站/百度竞价开户
  • 网站分类主要有哪些/企业培训课程ppt
  • 国外html响应式网站模板/站长seo查询工具