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

📄 testflyweightthreaded.java

📁 程序设计模式java入门源码大全
💻 JAVA
字号:
public class TestFlyweightThreaded implements Runnable
{
  Thread thread;

  public static void main(String args[])
  {
    TestFlyweightThreaded t = new TestFlyweightThreaded();
  }

  public TestFlyweightThreaded()
  {
    String names[] = {"Ralph", "Alice", "Sam"};
    int ids[] = {1001, 1002, 1003};
    int scores[] = {45, 55, 65};

    double total = 0;
    for (int loopIndex = 0; loopIndex < scores.length; loopIndex++){
      total += scores[loopIndex];
    }
 
    double averageScore = total / scores.length;

    StudentThreaded student = StudentThreaded.getInstance();

    student.setAverageScore(averageScore);
    student.setName("Ralph");
    student.setId(1002);
    student.setScore(45);

    thread = new Thread(this, "second");
    thread.start(); 

    System.out.println("Name: " + student.getName() +
      ", Standing: " + Math.round(student.getStanding()));
  }

  public void run() 
  {
    StudentThreaded student = StudentThreaded.getInstance();

    System.out.println("Name: " + student.getName() +
      ", Standing: " + Math.round(student.getStanding()));
  }
}

⌨️ 快捷键说明

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