testthread.java

来自「该文件在eclipse环境上运行」· Java 代码 · 共 32 行

JAVA
32
字号
package test.thread;

public class TestThread{

	public static void main(String[] args) {
		Thread t = new MyThread();
		t.start();
		t = new Thread(new MyThread2());
		t.start();
		for(int i=1; i<27; i++){
			System.out.print(Thread.currentThread());
			System.out.println("----" + i);
		}
		
	}
}
class MyThread extends Thread{
	public void run(){
		for(char c='a'; c<='z'; c++){
			System.out.print(Thread.currentThread());
			System.out.println("----" + c);
		}
	}
}
class MyThread2 implements Runnable{
	public void run() {
		for(char c='A'; c<='Z'; c++){
			System.out.print(Thread.currentThread());
			System.out.println("----" + c);
		}
	}
}

⌨️ 快捷键说明

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