testrunnable1.java

来自「java2 primer plus一书源程序」· Java 代码 · 共 43 行

JAVA
43
字号
/* * TestRunnable1.java * * Created on September 25, 2002, 12:08 PM */package ch18;/** * * @author  Stephen Potts */public class TestRunnable1 implements Runnable{        /** Creates a new instance of TestRunnable */    public TestRunnable1()    {    }        public void run()    {        for ( int i=0; i<10; i++)        {            System.out.println("Hello from the new thread");        }        Thread t = Thread.currentThread();        System.out.println("The Thread name is " + t.getName());    }        public static void main(String[] args)    {        TestRunnable1 tr1 = new TestRunnable1();        Thread t = new Thread(tr1);        t.start();                for (int i=1; i<10; i++)        {            System.out.println("Hello from the main thread");        }    }}

⌨️ 快捷键说明

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