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

📄 walkmanhire.java

📁 Java经典例程 从外国一大学计算机教授出版物下载的代码 经典
💻 JAVA
字号:
class WalkmanHire {

  /* The Museum Walkman Hire program      J M Bishop  Jan 1997
     simulates the hiring of Walkmen from a fixed pool for G1
     each. There are several helpers at different counters
     handling the hire and replacement of the Walkmen.

     The number of Walkmen in the original pool is 50
     and the number of helpers serving is 3,
     but these can be overridden by parameters at run time
     e.g. java WalkmanHire 100 8.
     The cash float starts at zero.

     Illustrates monitors, with synchronize, wait and notify.
     Shows a main program and two different kinds of threads
     running simultaneously.
  */

  public static void main (String [] args) {

    // Get the number of Walkmen in the pool
    // and open the museum for business.
    if (args.length >= 1)
      pool = Integer.parseInt(args[0]);
    else pool = 50;
    Museum m = new Museum (pool);
    // Get the number of helpers
    // and open the counters.
    if (args.length >= 2)
      helpers = Integer.parseInt(args[1]);
    else helpers = 3;
    for (int i=0; i<helpers; i++)
      new Counter (m,i).start();
  }
  static int pool;
  static int helpers;
}

⌨️ 快捷键说明

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