maskingthread.java

来自「这是一个基于计算网格的web service。它用java编写。一旦安装完成」· Java 代码 · 共 57 行

JAVA
57
字号
/* * MaskingThread.java * * Created on April 5, 2005, 5:25 PM */package jwsgrid.util.priv;import java.io.*;/** * This class attempts to erase characters echoed to the console. */public class MaskingThread extends Thread {    private boolean stop = false;    private int index;    private String prompt;  /**   *@param prompt The prompt displayed to the user   */   public MaskingThread( String prompt ) {      this.prompt = prompt;   }  /**   * Begin masking until asked to stop.   */   public void run() {      while ( !stop ) {         try {            // attempt masking at this rate            this.sleep( 1 );                     } catch ( InterruptedException iex ) {            iex.printStackTrace();         }                  if ( !stop ) {            System.out.print( "\r" + prompt + " \r" + prompt );         }                  System.out.flush();      }   }  /**   * Instruct the thread to stop masking.   */   public void stopMasking() {      this.stop = true;   }}

⌨️ 快捷键说明

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