亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? channel.java

?? 采用JAVA開發
?? JAVA
字號:
/*
  File: Channel.java

  Originally written by Doug Lea and released into the public domain.
  This may be used for any purposes whatsoever without acknowledgment.
  Thanks for the assistance and support of Sun Microsystems Labs,
  and everyone contributing, testing, and using this code.

  History:
  Date       Who                What
  11Jun1998  dl               Create public version
  25aug1998  dl               added peek
*/

package EDU.oswego.cs.dl.util.concurrent;

/** 
 * Main interface for buffers, queues, pipes, conduits, etc.
 * <p>
 * A Channel represents anything that you can put items
 * into and take them out of. As with the Sync 
 * interface, both
 * blocking (put(x), take),
 * and timeouts (offer(x, msecs), poll(msecs)) policies
 * are provided. Using a
 * zero timeout for offer and poll results in a pure balking policy.
 * <p>
 * To aid in efforts to use Channels in a more typesafe manner,
 * this interface extends Puttable and Takable. You can restrict
 * arguments of instance variables to this type as a way of
 * guaranteeing that producers never try to take, or consumers put.
 * for example:
 * <pre>
 * class Producer implements Runnable {
 *   final Puttable chan;
 *   Producer(Puttable channel) { chan = channel; }
 *   public void run() {
 *     try {
 *       for(;;) { chan.put(produce()); }
 *     }
 *     catch (InterruptedException ex) {}
 *   }
 *   Object produce() { ... }
 * }
 *
 *
 * class Consumer implements Runnable {
 *   final Takable chan;
 *   Consumer(Takable channel) { chan = channel; }
 *   public void run() {
 *     try {
 *       for(;;) { consume(chan.take()); }
 *     }
 *     catch (InterruptedException ex) {}
 *   }
 *   void consume(Object x) { ... }
 * }
 *
 * class Setup {
 *   void main() {
 *     Channel chan = new SomeChannelImplementation();
 *     Producer p = new Producer(chan);
 *     Consumer c = new Consumer(chan);
 *     new Thread(p).start();
 *     new Thread(c).start();
 *   }
 * }
 * </pre>
 * <p>
 * A given channel implementation might or might not have bounded
 * capacity or other insertion constraints, so in general, you cannot tell if
 * a given put will block. However,
 * Channels that are designed to 
 * have an element capacity (and so always block when full)
 * should implement the 
 * BoundedChannel 
 * subinterface.
 * <p>
 * Channels may hold any kind of item. However,
 * insertion of null is not in general supported. Implementations
 * may (all currently do) throw IllegalArgumentExceptions upon attempts to
 * insert null. 
 * <p>
 * By design, the Channel interface does not support any methods to determine
 * the current number of elements being held in the channel.
 * This decision reflects the fact that in
 * concurrent programming, such methods are so rarely useful
 * that including them invites misuse; at best they could 
 * provide a snapshot of current
 * state, that could change immediately after being reported.
 * It is better practice to instead use poll and offer to try
 * to take and put elements without blocking. For example,
 * to empty out the current contents of a channel, you could write:
 * <pre>
 *  try {
 *    for (;;) {
 *       Object item = channel.poll(0);
 *       if (item != null)
 *         process(item);
 *       else
 *         break;
 *    }
 *  }
 *  catch(InterruptedException ex) { ... }
 * </pre>
 * <p>
 * However, it is possible to determine whether an item
 * exists in a Channel via <code>peek</code>, which returns
 * but does NOT remove the next item that can be taken (or null
 * if there is no such item). The peek operation has a limited
 * range of applicability, and must be used with care. Unless it
 * is known that a given thread is the only possible consumer
 * of a channel, and that no time-out-based <code>offer</code> operations
 * are ever invoked, there is no guarantee that the item returned
 * by peek will be available for a subsequent take.
 * <p>
 * When appropriate, you can define an isEmpty method to
 * return whether <code>peek</code> returns null.
 * <p>
 * Also, as a compromise, even though it does not appear in interface,
 * implementation classes that can readily compute the number
 * of elements support a <code>size()</code> method. This allows careful
 * use, for example in queue length monitors, appropriate to the
 * particular implementation constraints and properties.
 * <p>
 * All channels allow multiple producers and/or consumers.
 * They do not support any kind of <em>close</em> method
 * to shut down operation or indicate completion of particular
 * producer or consumer threads. 
 * If you need to signal completion, one way to do it is to
 * create a class such as
 * <pre>
 * class EndOfStream { 
 *    // Application-dependent field/methods
 * }
 * </pre>
 * And to have producers put an instance of this class into
 * the channel when they are done. The consumer side can then
 * check this via
 * <pre>
 *   Object x = aChannel.take();
 *   if (x instanceof EndOfStream) 
 *     // special actions; perhaps terminate
 *   else
 *     // process normally
 * </pre>
 * <p>
 * In time-out based methods (poll(msecs) and offer(x, msecs), 
 * time bounds are interpreted in
 * a coarse-grained, best-effort fashion. Since there is no
 * way in Java to escape out of a wait for a synchronized
 * method/block, time bounds can sometimes be exceeded when
 * there is a lot contention for the channel. Additionally,
 * some Channel semantics entail a ``point of
 * no return'' where, once some parts of the operation have completed,
 * others must follow, regardless of time bound.
 * <p>
 * Interruptions are in general handled as early as possible
 * in all methods. Normally, InterruptionExceptions are thrown
 * in put/take and offer(msec)/poll(msec) if interruption
 * is detected upon entry to the method, as well as in any
 * later context surrounding waits. 
 * <p>
 * If a put returns normally, an offer
 * returns true, or a put or poll returns non-null, the operation
 * completed successfully. 
 * In all other cases, the operation fails cleanly -- the
 * element is not put or taken.
 * <p>
 * As with Sync classes, spinloops are not directly supported,
 * are not particularly recommended for routine use, but are not hard 
 * to construct. For example, here is an exponential backoff version:
 * <pre>
 * Object backOffTake(Channel q) throws InterruptedException {
 *   long waitTime = 0;
 *   for (;;) {
 *      Object x = q.poll(0);
 *      if (x != null)
 *        return x;
 *      else {
 *        Thread.sleep(waitTime);
 *        waitTime = 3 * waitTime / 2 + 1;
 *      }
 *    }
 * </pre>
 * <p>
 * <b>Sample Usage</b>. Here is a producer/consumer design
 * where the channel is used to hold Runnable commands representing
 * background tasks.
 * <pre>
 * class Service {
 *   private final Channel channel = ... some Channel implementation;
 *  
 *   private void backgroundTask(int taskParam) { ... }
 *
 *   public void action(final int arg) {
 *     Runnable command = 
 *       new Runnable() {
 *         public void run() { backgroundTask(arg); }
 *       };
 *     try { channel.put(command) }
 *     catch (InterruptedException ex) {
 *       Thread.currentThread().interrupt(); // ignore but propagate
 *     }
 *   }
 * 
 *   public Service() {
 *     Runnable backgroundLoop = 
 *       new Runnable() {
 *         public void run() {
 *           for (;;) {
 *             try {
 *               Runnable task = (Runnable)(channel.take());
 *               task.run();
 *             }
 *             catch (InterruptedException ex) { return; }
 *           }
 *         }
 *       };
 *     new Thread(backgroundLoop).start();
 *   }
 * }
 *    
 * </pre>
 * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
 * @see Sync 
 * @see BoundedChannel 
**/

public interface Channel extends Puttable, Takable {

  /** 
   * Place item in the channel, possibly waiting indefinitely until
   * it can be accepted. Channels implementing the BoundedChannel
   * subinterface are generally guaranteed to block on puts upon
   * reaching capacity, but other implementations may or may not block.
   * @param item the element to be inserted. Should be non-null.
   * @exception InterruptedException if the current thread has
   * been interrupted at a point at which interruption
   * is detected, in which case the element is guaranteed not
   * to be inserted. Otherwise, on normal return, the element is guaranteed
   * to have been inserted.
  **/
  public void put(Object item) throws InterruptedException;

  /** 
   * Place item in channel only if it can be accepted within
   * msecs milliseconds. The time bound is interpreted in
   * a coarse-grained, best-effort fashion. 
   * @param item the element to be inserted. Should be non-null.
   * @param msecs the number of milliseconds to wait. If less than
   * or equal to zero, the method does not perform any timed waits,
   * but might still require
   * access to a synchronization lock, which can impose unbounded
   * delay if there is a lot of contention for the channel.
   * @return true if accepted, else false
   * @exception InterruptedException if the current thread has
   * been interrupted at a point at which interruption
   * is detected, in which case the element is guaranteed not
   * to be inserted (i.e., is equivalent to a false return).
  **/
  public boolean offer(Object item, long msecs) throws InterruptedException;

  /** 
   * Return and remove an item from channel, 
   * possibly waiting indefinitely until
   * such an item exists.
   * @return  some item from the channel. Different implementations
   *  may guarantee various properties (such as FIFO) about that item
   * @exception InterruptedException if the current thread has
   * been interrupted at a point at which interruption
   * is detected, in which case state of the channel is unchanged.
   *
  **/
  public Object take() throws InterruptedException;


  /** 
   * Return and remove an item from channel only if one is available within
   * msecs milliseconds. The time bound is interpreted in a coarse
   * grained, best-effort fashion.
   * @param msecs the number of milliseconds to wait. If less than
   *  or equal to zero, the operation does not perform any timed waits,
   * but might still require
   * access to a synchronization lock, which can impose unbounded
   * delay if there is a lot of contention for the channel.
   * @return some item, or null if the channel is empty.
   * @exception InterruptedException if the current thread has
   * been interrupted at a point at which interruption
   * is detected, in which case state of the channel is unchanged
   * (i.e., equivalent to a null return).
  **/

  public Object poll(long msecs) throws InterruptedException;

  /**
   * Return, but do not remove object at head of Channel,
   * or null if it is empty.
   **/

  public Object peek();

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合一个色综合| 在线成人午夜影院| 国产乱子轮精品视频| 日韩av一区二区三区四区| 夜夜精品浪潮av一区二区三区| 国产精品视频你懂的| 国产精品免费视频一区| 国产精品久久久久久久久久免费看| 精品成人a区在线观看| 久久久一区二区| 国产日韩精品一区二区浪潮av | 中文在线免费一区三区高中清不卡| 日韩写真欧美这视频| 精品美女被调教视频大全网站| 日韩欧美你懂的| 欧美精品一区二| 国产日产亚洲精品系列| 中文字幕欧美激情一区| 专区另类欧美日韩| 天堂在线一区二区| 国产专区欧美精品| 99精品热视频| 欧美优质美女网站| 777午夜精品免费视频| 久久久久久久免费视频了| 国产精品你懂的在线| 亚洲综合视频在线| 久久99久久久久久久久久久| 国产成人一级电影| 91国偷自产一区二区开放时间| 欧美日韩视频在线第一区 | 亚洲视频1区2区| 日一区二区三区| 国产一区二区三区四| 色综合久久久久综合| 日韩一级在线观看| 中文字幕亚洲电影| 免费一区二区视频| 97se狠狠狠综合亚洲狠狠| 欧美日本视频在线| 国产精品久久久久久久蜜臀| 日日夜夜一区二区| 99视频一区二区| 欧美不卡视频一区| 亚洲激情综合网| 国产成人丝袜美腿| 欧美日韩精品一区二区三区| 国产亚洲成aⅴ人片在线观看| 亚洲最新在线观看| 成人毛片视频在线观看| 日韩欧美一二三区| 亚洲成年人网站在线观看| 国产999精品久久| 日韩丝袜情趣美女图片| 亚洲乱码中文字幕综合| 岛国精品一区二区| 91精品国产综合久久久久| 亚洲日本va午夜在线影院| 精品在线播放免费| 久久久电影一区二区三区| 日日夜夜精品视频天天综合网| 97aⅴ精品视频一二三区| 欧美国产一区二区| 精品一区二区在线观看| 91国偷自产一区二区三区成为亚洲经典 | 午夜精品福利在线| 99re热这里只有精品免费视频| 久久精品视频网| 蜜臀久久99精品久久久久宅男 | 欧美精品日韩综合在线| 亚洲激情六月丁香| 94-欧美-setu| 亚洲丝袜美腿综合| www.亚洲免费av| 国产精品久久久久久福利一牛影视| 蜜臀久久久99精品久久久久久| 91麻豆精品国产自产在线| 亚洲图片一区二区| 欧美日韩免费观看一区二区三区 | 亚洲电影视频在线| 91福利国产精品| 亚洲成人午夜电影| 欧美久久久影院| 免费av网站大全久久| 日韩三级高清在线| 国内精品国产成人| 国产亚洲1区2区3区| 成人高清免费观看| 亚洲欧美国产77777| 欧美做爰猛烈大尺度电影无法无天| 亚洲激情图片qvod| 51精品秘密在线观看| 麻豆91在线看| 国产精品入口麻豆原神| 一本大道av伊人久久综合| 一区二区三区欧美| 欧美一区午夜视频在线观看| 美女视频第一区二区三区免费观看网站| 日韩欧美亚洲另类制服综合在线| 久久精品国产亚洲一区二区三区| 久久精品视频在线免费观看| 91女厕偷拍女厕偷拍高清| 亚洲二区在线观看| 亚洲精品一区二区精华| 成人激情免费电影网址| 亚洲精品伦理在线| 精品奇米国产一区二区三区| 国产成人午夜精品影院观看视频 | 欧美午夜精品久久久久久超碰| 婷婷成人激情在线网| 国产清纯美女被跳蛋高潮一区二区久久w | 韩国精品一区二区| 亚洲欧美另类久久久精品| 日韩三级高清在线| 91在线一区二区| 人妖欧美一区二区| 中文字幕一区二区三区精华液 | www国产精品av| 99精品视频在线观看免费| 婷婷综合在线观看| 国产精品美女久久久久av爽李琼 | 日日噜噜夜夜狠狠视频欧美人 | 亚洲区小说区图片区qvod| 欧美一区二区三区在线| jvid福利写真一区二区三区| 日韩国产高清影视| 日韩一区二区三区在线| 色屁屁一区二区| 国产九色精品成人porny| 图片区小说区区亚洲影院| 亚洲国产精品精华液ab| 日韩精品中文字幕在线不卡尤物| 色欧美乱欧美15图片| 国产v综合v亚洲欧| 欧美日韩精品一区二区三区四区| 国产成人夜色高潮福利影视| 另类小说图片综合网| 图片区小说区区亚洲影院| 一区二区三区四区乱视频| 国产日韩欧美一区二区三区综合| 91麻豆精品国产91久久久久久| 色婷婷综合在线| 成a人片亚洲日本久久| 狠狠色综合色综合网络| 毛片一区二区三区| 日本中文字幕不卡| 丝袜a∨在线一区二区三区不卡| 一区二区三区在线影院| 亚洲老司机在线| 中文字幕欧美国产| 国产欧美日韩麻豆91| 国产日韩欧美亚洲| 国产欧美日韩另类一区| 日本一区二区三区免费乱视频| 久久久久久一二三区| 国产喂奶挤奶一区二区三区| 2020国产精品| 日本一区二区三区四区在线视频| 久久天堂av综合合色蜜桃网| 337p粉嫩大胆色噜噜噜噜亚洲 | 成人高清免费在线播放| 丰满亚洲少妇av| 大陆成人av片| 99精品久久只有精品| 91高清在线观看| 欧美无乱码久久久免费午夜一区| 欧美视频一区二区| 91精品欧美久久久久久动漫| 精品久久久影院| 久久夜色精品国产欧美乱极品| 国产欧美日韩久久| 自拍偷拍亚洲综合| 天天综合色天天综合色h| 免费高清成人在线| 大胆亚洲人体视频| 欧洲激情一区二区| 欧美一区二区播放| 国产欧美日韩亚州综合| 1024成人网| 日韩专区欧美专区| 国产精品影视在线观看| 91丝袜美腿高跟国产极品老师 | 国产精品第四页| 亚洲一二三四在线| 麻豆91在线观看| 成人福利电影精品一区二区在线观看| 97精品视频在线观看自产线路二| 欧美私模裸体表演在线观看| 日韩精品一区二区三区中文精品 | 成人黄色一级视频| 在线观看成人小视频| 日韩欧美美女一区二区三区| 国产精品美女久久久久久久网站| 亚洲图片一区二区| 国产精品一区专区| 欧美三级中文字幕| 国产精品久久久久一区二区三区 | 大白屁股一区二区视频| 欧美日韩国产免费| 国产精品美日韩|