testtwothreads1.java

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

JAVA
42
字号
/* * TestTwoThreads1.java * * Created on September 25, 2002, 12:08 PM */package ch18;/** * * @author  Stephen Potts */public class TestTwoThreads1 extends Thread{        /** Creates a new instance of TestTwoThreads1 */    public TestTwoThreads1()    {    }        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)    {        TestTwoThreads1 ttt1 = new TestTwoThreads1();        ttt1.start();                for (int i=1; i<10; i++)        {            System.out.println("Hello from the main thread");        }    }}

⌨️ 快捷键说明

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