visitors.java

来自「Java经典例程 从外国一大学计算机教授出版物下载的代码 经典」· Java 代码 · 共 22 行

JAVA
22
字号
class Visitors extends Thread {

  Visitors (Museum m, int w) {
    museum = m;
    groupSize = w;
  }

  public void run () {

    // The group walks around on its own for 50 time units.
    // You may need to alter this figure to suit your computer.
    // They then replace all their Walkmen and leave.
    // The thread dies with them.
    try {sleep((int) (Math.random()*1000)+1);}
          catch(InterruptedException e) {}
    museum.replace(groupSize);
  }

  Museum museum;
  int groupSize;
}

⌨️ 快捷键说明

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