testthread.java

来自「介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识」· Java 代码 · 共 28 行

JAVA
28
字号
		class TestThread extends Thread {
			private String whoami;
			private int delay;
			public TestThread(String s, int d) {
				whoami = s;
				delay = d;
			} 
			public void run() {
				try {
					sleep(delay);
				}
				catch(InterruptedException e) {	}
				System.out.println( "Hello World!"+whoami+""+delay );
				}
			}
			public class multitest {
				public static void main(String args[]) {
					TestThread t1,t2,t3;
					t1 = new TestThread("Thread1",(int)(Math.readom()*2000));
					t2 = new TestThread("Thread2",(int)(Math.readom()*2000));
					t3 = new TestThread("Thread3",(int)(Math.readom()*2000));
					t1.start();
					t2.start();
					t3.start();
				}
			}
		}

⌨️ 快捷键说明

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