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

📄 logger.java

📁 一步 教你学会java 完成一个完整的SWT系统 是本人学习java时按教程一步一步写下来的咯
💻 JAVA
字号:
/** *  Example code for JavaOne hands-on J2SE lab * *  Concurrency utilities (JSR-166) example **/package queue;import java.net.*;import java.io.*;import java.util.concurrent.*;/** *  Runnable that consumes information placed in a blocking queue.  This *  demonstrates the simple synchonisation that can be achieved with the *  new BlockingQueue class. **/public class Logger implements Runnable {  private BlockingQueue<String> messageQueue;  /**   *  Constructor   *   * @param messageQueue The queue that will be used to pass messages   * between the two threads   **/  public Logger(BlockingQueue<String> messageQueue) {    this.messageQueue = messageQueue;  }     /**   *  Run method simply takes messages from the queue when they're there   *  and pushes them to the stdout   **/  public void run() {    try {      while (true) {        System.out.println("LOG MSG: " + messageQueue.take());      }    } catch (InterruptedException ie) {      // Ignore    }  }}

⌨️ 快捷键说明

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