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

📄 multitest.java

📁 介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识
💻 JAVA
字号:
//Define our simple threads.They will pause for a short time//and then print out their names and delay timesclass TestThread extends Thread {    private String whoami;    private int delay;    //Our constructor to store the name (whoami)    //and time to sleep (delay)    public TestThread(String s, int d) { whoami = s; delay = d; }    //Run - the thread method similar to main()    //When run is finished, the thread dies.    //Run is called from the start() method of Thread    public void run() {        //Try to sleep for the specified time        try { sleep(delay); }        catch(InterruptedException e) {}        //Now print out our name        System.out.println("Hello World!"+whoami+"="+delay); }    }    /** * Multimtest. A simple multithread thest program */    public class multitest {        public static void main(String args[]) {            TestThread t1,t2,t3;            //Create our test threads            t1 = new TestThread("Thread1",(int)(Math.random()*2000));            t2 = new TestThread("Thread2",(int)(Math.random()*2000));            t3 = new TestThread("Thread3",(int)(Math.random()*2000));            //Start each of the threads            t1.start();            t2.start();            t3.start();        }}

⌨️ 快捷键说明

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