Runnable案例

package xiancheng;

public class TestRun {

    public static void main(String[] args) {
    //1.创建一个线程体
        Task task=new Task();
        Thread t=new Thread(task);
        Thread t1=new Thread(task);
        t.start();
        t1.start();
//new Thread(new Task()).start(); } }
//创建一个线程体; class Task implements Runnable{ @Override public void run() { for(int i=0;i<100;i++){ System.out.println(Thread.currentThread().getName()+":  "+i); } } }

 

posted @ 2017-05-13 19:06  苏轼的红烧肉  阅读(138)  评论(0编辑  收藏  举报