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