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

📄 runnabletest.java

📁 JAVA编程百例书中各章节的所有例子的源代码,包括套接字编程
💻 JAVA
字号:
package ch01.section10;

public class RunnableTest
    implements Runnable {
  //run()中while循环的次数
  private int countDown = 5;
  private static int threadCount = 0;

  //记录线程数
  private int threadNumber = ++threadCount;

  //构造函数
  public RunnableTest() {
    //打印这是第几个线程
    System.out.println("RunnableTest " + threadNumber);
  }

  public void run() {
    while (true) {
      //循环打印
      System.out.println("Runnable " +
                         threadNumber + "(" + countDown + ")");
      //每循环一次记数器减一
      if (--countDown == 0) {
        return;
      }
    }
  }

}

⌨️ 快捷键说明

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