java 多线程 方法2 使用Runnable接口

来源:互联网 发布:重庆大学软件工程学院 编辑:程序博客网 时间:2024/06/05 19:34
class Demo implements Runnable{private int num=100;public void run() {while(num>0)System.out.println(Thread.currentThread().getName()+"..."+num--);}}public class main {public static void main(String[] args) {Demo D=new Demo();Thread t1=new Thread(D);Thread t2=new Thread(D);t1.start();t2.start();}}


原创粉丝点击