注册 登录
悉远 返回首页

焰阳小窝 http://bbs.7cuu.com/?1 [收藏] [复制] [分享] [RSS]

日志

多线程

已有 540 次阅读2011-1-11 13:23 |个人分类:java|

public class a {

     public static void main(String args[]) {

     WriteWordThread zhang ,wang,xue;

     zhang=new WriteWordThread("张小红",100);

     wang=new WriteWordThread("JamsKeven",200);

     xue=new WriteWordThread("xiaoxue",100);

     zhang.start();

     wang.start();

     xue.start();

    }

}

class WriteWordThread extends Thread{

int  n=0;

WriteWordThread(String s,int n){

setName(s);

this.n=n;

}

public void run(){

for(int i=1;i<=8;i++){

System.out.println("我是一个线程,我的名字是"+getName());

    try{

     sleep(n);

    }

    catch(InterruptedException e){}

    }

    }

}


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|QQ客服|联系我们|Archiver|手机版|小黑屋|悉远网络 ( 鄂ICP备09013446号 )

GMT+8, 2024-5-17 10:32 , Processed in 0.026768 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

返回顶部