51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1891|回复: 5
打印 上一主题 下一主题

List集合中,启动线程的功能该如何做呢?

[复制链接]
  • TA的每日心情
    开心
    2024-4-29 20:15
  • 签到天数: 1001 天

    连续签到: 1 天

    [LV.10]测试总司令

    1#
    发表于 2020-5-29 09:30:54 | 显示全部楼层
    public class MYThread extends Thread {
    private int beg;
    private int end;

    public MYThread (int beg,int end){
        this.beg=beg;
        this.end=end;   }

    @Override
    public void run() {
        this.gramDis();
    }

       public void gramDis(){
    //写具体打印代码
    }

    }
    //调用
    public class StartThread(){
    public static void main(String[] args) {
    MYThread th1=new MYThread (1,1000);
    MYThread th2=new MYThread (1,1000);
    th1.start();
    th2.start();
    }
    }
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-7 01:09 , Processed in 0.058376 second(s), 21 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表