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

📄 adder.java

📁 java实现的线程同步
💻 JAVA
字号:


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Adder extends Thread{
  private CubbyHole cubbyhole;
    private int number;

      public Adder(CubbyHole c, int number) {
            cubbyhole = c;
            this.number = number;
        }

        public void run() {
            for (int i = 0; i < 10; i++) {
               cubbyhole.add();
                System.out.println("Adder#" + this.number
                                   + " add: 10" );
   try {
                sleep((int)(Math.random() * 100));
            } catch (InterruptedException e) { }
             


            }
        }
    }

⌨️ 快捷键说明

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