⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fifoslot.java

📁 采用JAVA开发
💻 JAVA
字号:
package EDU.oswego.cs.dl.util.concurrent.misc;
import  EDU.oswego.cs.dl.util.concurrent.*;


// demo showing one way to make special channels

public class FIFOSlot implements BoundedChannel {
  private final Slot slot_;

  public FIFOSlot() {
    try {
      slot_ = new Slot(FIFOSemaphore.class);
    }
    catch (Exception ex) {
      ex.printStackTrace();
      throw new Error("Cannot make Slot?");
    }
  }

  public void put(Object item) throws InterruptedException { 
    slot_.put(item); 
  }

  public boolean offer(Object item, long msecs) throws InterruptedException {
    return slot_.offer(item, msecs);
  }

  public Object take() throws InterruptedException { 
    return slot_.take(); 
  }

  public Object poll(long msecs) throws InterruptedException {
    return slot_.poll(msecs);
  }

  public int capacity() { return 1; }

  public Object peek() {
    return slot_.peek();
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -