test.java

来自「PracticalJAVACode 的源码」· Java 代码 · 共 29 行

JAVA
29
字号
class Foo implements Runnable
{
  public synchronized void printM1()
  {
    while (true)
      System.out.println("printM1");
  }

  public synchronized static void printM2()
  {
    while (true)
      System.out.println("printM2");
  }
  public void run()
  {
    printM1();
  }
}

class Test
{
  public static void main(String args[])
  {
    Foo f = new Foo();
    Thread t = new Thread(f);
    t.start();
    f.printM2();
  }
}

⌨️ 快捷键说明

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