<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > ### `LinkedBlockingQueue` * `FixedThreadPool`和`SingleThreadExecutor`中的阻塞隊列 <br/> > ### `SynchronousQueue` * `CachedThreadPool`中的阻塞隊列 <br/> > ### `DelayQueue` * `ScheduledThreadPoolExecutor`中的阻塞隊列 * 使用實例,元素需要繼承`Delayed`接口 ``` public class DelayQueueTest { static class Element implements Delayed{ long expireTime; String msg; public Element(long expireTime, String msg){ this.expireTime = expireTime; this.msg = msg; } @Override public long getDelay(TimeUnit unit) { return unit.convert(this.expireTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS); } @Override public int compareTo(Delayed o) { return (int) (this.getDelay(TimeUnit.MILLISECONDS) -o.getDelay(TimeUnit.MILLISECONDS)); } } public static void main(String[] args) { DelayQueue delayQueue = new DelayQueue(); long now = System.currentTimeMillis(); delayQueue.add(new Element(now + 1000, "1")); delayQueue.add(new Element(now + 2000, "2")); delayQueue.add(new Element(now + 3000, "3")); while(!delayQueue.isEmpty()){ try{ Element e = (Element) delayQueue.take(); System.out.println(e.msg); }catch(InterruptedException e){ e.printStackTrace(); } } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看