- import java.lang.*;
- class Demo1 implements Runnable{
- public void run(){
- show();
- }
- public void show(){
- for(int i=0;i<10;i++)
- System.out.println(Thread.currentThread().getName()+"..."+i);
- }}
- class ThreadDemo{
- public static void main(String[] args){
- Demo1 d= new Demo1();
- Thread t1 = new Thread(d);
- Thread t2 = new Thread(d);
- t1.start();
- t2.start();
- }
- }
复制代码 |