complete11_1.java

来自「北京大学出版社的」· Java 代码 · 共 26 行

JAVA
26
字号
package questions.c11;
public class Complete11_1 implements Runnable {
   private String message;
   private int pause;
   private boolean keepGoing = true;
   public Complete11_1( String m, int p ) {
      message = m;
      pause = p;
   }
   public void requestStop() {
      keepGoing = false;
   }
   public void run() {
      while ( keepGoing ) {
         System.out.println( message );
         try {
            Thread.currentThread().sleep( pause );
         } catch ( InterruptedException ix ) {
            System.out.println( ix );
         }
      }
   }
   public static void main( String[] args ) {
      // Your code here
   }
}

⌨️ 快捷键说明

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